patrickkunka / mixitup

A high-performance, dependency-free library for animated filtering, sorting, insertion, removal and more
https://www.kunkalabs.com/mixitup/
4.52k stars 735 forks source link

JS error with getFilterGroupSelectors (Multifilter API) #534

Closed AnInfiniteNumberofMonkeys closed 4 years ago

AnInfiniteNumberofMonkeys commented 4 years ago

I'm getting the error:

Uncaught TypeError: Cannot read property 'getFilterGroupSelectors' of undefined

I just can't figure out where it's coming from. Any assistance you can provide on where it's coming from would be appreciated.

Page: http://fishinglodgesandresorts.com/search

The error appears as soon as the page loads (I try to build a hash based on current filters). The only way i can get around the issue is if I comment out every line that uses "getFilterGroupSelectors".

AnInfiniteNumberofMonkeys commented 4 years ago

Is anybody monitoring this thread?

patrickkunka commented 4 years ago

Hi @Deralict - thanks for the link. it seems highly likely that your hash code is being called before the mixer variable is defined. Looking into it now.

AnInfiniteNumberofMonkeys commented 4 years ago

I'm not sure that's a possibility, as the function (that calls getFilterGroupSelectors) is called only with "onMixEnd" as part of the mixer variable definition. Here is how I'm defining the variable:

    var mixer = mixitup(containerEl, {
        load: {
            sort: 'type:asc'
        },
        multifilter: {
            enable: true,
            logicWithinGroup: "or",
            logicBetweenGroups: "and"
        },
        callbacks: {
            onMixStart: function(state, futureState) {
                $("#lodgeCount").html('<div class="spinner"><img src="/wp-content/uploads/filter-loader.gif" width="60" height="8"></div><span>Searching...</span>');
                placePins(futureState);
                fitPins();
                //updateMapState(futureState);
            },
            onMixEnd: setHash
        }
    });

"setHash" is where I create the hash based on the current filters, and that's where getFilterGroupSelectors is called.

But hopefully I'm missing something really obvious.

patrickkunka commented 4 years ago

Hi there - apologies - after much head scratching have just realised this is a bug that was introduced in multifilter 3.3.5 in October but had not been spotted until now. It only effects fieldsets with input elements in them and when using the programmatic filtering by URL code, which the demo doesn't have.

I'm pushing a patch now. Will let you know when its available to download.

patrickkunka commented 4 years ago

Please download v3.3.6 from your account and let me know if it fixes the issue.

AnInfiniteNumberofMonkeys commented 4 years ago

That worked...sort of. I've moved past the error, but I'm now stuck at a different one. I don't believe this one is a bug—I'm confident it's something I've done or not done. But I was wondering if you'd be able to take a look and make a suggestion about how to fix it?

Same page. I'm now getting Uncaught DOMException: Failed to execute 'matches' on 'Element': '.2d' is not a valid selector.

if I select and of the Trip Duration filters (Trip tab).

AnInfiniteNumberofMonkeys commented 4 years ago

Update: I've overcome that issue also—I had a malfomed class name.

Now my only issue is that the "onMixEnd" callback is not running the very first time (when the page loads and the mixer variable is defined. It's the same code as above...my setHash function doesn't execute unless I change a filter input. Any ideas?

patrickkunka commented 4 years ago

I'm unable to debug that last one as there seems to be more serious issues with your site which weren't there yesterday - the CSS seems to be broken and the mixitup library is not loaded at all. Let me know when all that's working again and I'll be happy to take a look.

AnInfiniteNumberofMonkeys commented 4 years ago

Hi Patrick...you happened to catch the site in flux while I was debugging this myself. I eventually found the problem and it's now working. Thanks

patrickkunka commented 4 years ago

Great, good to hear. I will close the issue now.