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

MixItUp with jScroll #200

Closed rombat closed 7 years ago

rombat commented 9 years ago

Hi,

I filter and sort some elements with MixItUp on a page using jScroll (infinite scrolling).

The thing is, I'd like to refresh mixitup every time jscroll is triggered.

$('div.scroll').jscroll({
            autoTrigger: true,
            padding:200,
            nextSelector: '.pagination li.active + li a',
            contentSelector: 'div.scroll',
            callback: function() {
                $('ul.pagination:visible:first').hide();
                // $('.mix').show();
                var last = $('.scroll').last().children('.mix');
                $('#Container').mixItUp('append', last);
            }
        });

I've tried the 'append' method but it doesn't seem to be working (in Chrome console): Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

I've also tried to reset the filters/sort with something like that:

 $('#Container').mixItUp('filter', 'all');
 $('#Container').mixItUp('sort', 'price:asc');

But I've got this error: Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. I've also tried with getState method (to get the last filter / sort), but I've got the same error.

I don't know if it's related to jScroll or if the origin of the problem is elsewhere. Any idea of to fix this? I'm using MixItUp 2.1.7 by the way.

patrickkunka commented 7 years ago

MixItUp 3's insert API is now a lot more robust, so this kind of issue so no longer be a problem.

https://github.com/patrickkunka/mixitup/releases/tag/v3.0.0