Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add event to LeafletWidget? #325

Open
eruiz67 opened this issue May 27, 2021 · 1 comment
Open

How to add event to LeafletWidget? #325

eruiz67 opened this issue May 27, 2021 · 1 comment

Comments

@eruiz67
Copy link

eruiz67 commented May 27, 2021

In my django app I have a Worker model with a name and location (Point). Using django-leflet LeafletWidget I can create a Form where the user can set a location (marker to that worker).
Is it possible to add an event to the widget, so, every time the user sets the marker, or change the marker position it gets the coordinates of that point and perform other actions (like an ajax request)?

class WorkerForm(forms.ModelForm):
    
    class Meta:
        model = WorkerModel
        exclude = ("id",)
        widgets = {
            'name':forms.TextInput(attrs={'class': 'form-control'}),
            'location': LeafletWidget(),
}

in the template i just call
'forms.location'
and it renders the map with the controls to set a marker

@Gagaro
Copy link
Member

Gagaro commented Jun 7, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants