I'm aware you can set an "on popup close" event on the map
object in leaflet, is there any way to set that on a per-popup basis?
If I have a layer taken from an event like so...
var layer = event.layer;
var bound = layer.bindPopup(
"blah",
{closeButton: false, closeOnClick: false}
);
var popUp = bound.openPopup();
I would like to conditionally set an on-close event for this popup based on a condition. The issue I am facing is that when they draw a shape, I open a popup to allow them to name it. However, if they click on the shape while this popUp is open, it runs the "click" event which opens ANOTHER popup to edit it. I'd like to avoid this and make it so that if they close the first popup without setting a name, it removes the shape entirely.
There is no an onClose, but there is an onRemove. This is fired when you close the popup:
marker.getPopup().on('remove', function() {
//Your code here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With