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

Can't manage to listen popupopen and popupclose events #63

Open
lamuertepeluda opened this issue Apr 29, 2015 · 2 comments
Open

Can't manage to listen popupopen and popupclose events #63

lamuertepeluda opened this issue Apr 29, 2015 · 2 comments

Comments

@lamuertepeluda
Copy link

Hi, great job!

I'm trying to listen to http://leafletjs.com/reference.html#marker-popupopen

inside my PrepareLeafletMarker override function, which I made following this example.
However, 'popupopen' never gets fired, nor does its dual 'popupclose', while 'click' does.

I need this to set a listener on the popup content once it is open.

I don't really get why...

@fungiboletus
Copy link
Member

Hello,

I did a quick test and I can reproduce the problem. I don't know why it doesn't work, it could be something related to Leaflet and how the markers are created by PruneCluster. I don't have the time to investigate the problem but I can suggest a workaround : by listening to popupopen events on the map object like this:

    leafletView.PrepareLeafletMarker = function(leafletMarker, data) {
        var popup = leafletMarker.getPopup();
        if (!popup) {
            popup = L.popup();
            leafletMarker.bindPopup(popup);
        }
        popup.setContent(data.popup);

        // Attach the data object
        popup.data = data;
    };

    map.on('popupopen', function(e) {
        if (e.popup.data) {
            alert(e.popup.data.something);
        }
    });

I hope it helps

@lamuertepeluda
Copy link
Author

Thank you, I had also found this kind of workaround! :)

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