XF 2.0 Running JS on the FilterMenu, closes the menu?

Jaxel

Well-known member
I'm having issues when running a javascript on a menu... example in this video:

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

This is the script that causes the issue:
Code:
    EWRatendo.address = XF.Element.newHandler(
    {
        init: function()
        {
            this.$target.find('.atendo-address').geocomplete();
        },
    });
    XF.Element.register('atendo-address', 'EWRatendo.address');
using: https://ubilabs.github.io/geocomplete/
 
Any click outside of a menu will close the menu. This is a fairly difficult problem and it's very possible our own auto-complete APIs would trigger the same thing.

As the element isn't a child of the menu itself, it would be considered unrelated and thus close the menu. The simple solution would involve having the library allow the insertion with the menu, though that does affect positioning so I can understand why they don't do that. Unfortunately, there isn't really a simple workaround that I can see.
 
A possible solution could be to place .pac-container inside your filter on geocode:result event.

Code:
$(document).on('geocode:result', function(event){
    $('body > .pac-container').appendTo('.menu:visible');
});

That will break positioning, so you'll have to fix it yourself unfortunately.
 
Last edited:
Back
Top Bottom