Skip to content

Commit

Permalink
update leaflet interactive widget Javascript Triggers documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
erdem committed Jul 25, 2024
1 parent 1b410ec commit df3b65a
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions docs/widgets/leaflet/PointField/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,4 @@ In the Django project settings file, the `MAP_WIDGETS` dictionary should be defi
Javascript Triggers
^^^^^^^^^^^^^^^^^^^

UI customization or event handling on the front-end can be managed using map widget jQuery triggers. Examples of usage can be found in the `demo project <https://github.com/erdem/django-map-widgets/tree/main/demo>`_.

* **leafletPointFieldWidget:markerCreate**: Triggered when a marker is created on the map. (callback params: place, lat, lng, locationInputElem, mapWrapID)

* **leafletPointFieldWidget:markerChange**: Triggered when a marker's position is changed on the map. (callback params: place, lat, lng, locationInputElem, mapWrapID)

* **leafletPointFieldWidget:markerDelete**: Triggered when a marker is deleted from the map. (callback params: lat, lng, locationInputElem, mapWrapID)


.. code-block:: javascript
(function ($) {
$(document).on("leafletPointFieldWidget:markerCreate", function (e, lat, lng, locationInputElem, mapWrapID) {
console.log(locationInputElem); // Django widget textarea widget (hidden)
console.log(lat, lng); // Created marker coordinates
console.log(mapWrapID); // Map widget wrapper element ID
});
$(document).on("leafletPointFieldWidget:markerChange", function (e, lat, lng, locationInputElem, mapWrapID) {
console.log(locationInputElem); // Django widget textarea widget (hidden)
console.log(lat, lng); // Changed marker coordinates
console.log(mapWrapID); // Map widget wrapper element ID
});
$(document).on("leafletPointFieldWidget:markerDelete", function (e, lat, lng, locationInputElem, mapWrapID) {
console.log(locationInputElem); // Django widget textarea widget (hidden)
console.log(lat, lng); // Deleted marker coordinates
console.log(mapWrapID); // Map widget wrapper element ID
});
console.log($("#location-map-elem").data("mwMapObj")); // Leaflet Map JS object
console.log($("#location-map-elem").data("mwClassObj")); // The widget class instance object
})(jQuery)
There is no jQuery event trigger support for this widget yet.

0 comments on commit df3b65a

Please sign in to comment.