Skip to content

Events inside popup don't propagate outside the map #301

@jones139

Description

@jones139

I am trying to create a popup on a marker, which contains buttons, but I am having trouble with events not firing from the buttons on the marker popup.

I create the popup with
function addMarker(e) {
var marker = new L.Marker(e.data.latlng,{clickable:true, draggable:true});
map.addLayer(marker);
var content = "Marker " +
"Delete Marker" +
"Cancel";
marker.bindPopup(content);
marker.on('dragend',onMarkerDragEnd);
map.closePopup(popup);
}

And try to catch the event from the button with:
jQuery('#deleteMarker').live('click',function(e) { alert('delete'); });

Similar code that just adds a popup to the map works, but the above does not when the popup is bound to a marker.

I have tried modifying Popup.js to remove the disableClickPropagation command (line 81 - https://github.com/jones139/Leaflet/commit/117db3515c6b8070e0d2c42ff4bc1030fe5feef4), and this gets my events working, but the clicks also propagate down to the map. Therefore I think it is an issue in Leaflet somewhere?.....Or I may be doing it wrong!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions