Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I redraw and reorganise the elements within an Isotope container upon reordering the DOM?

As per this JSFiddle, I create an Isotope container which contains each of my elements, upon clicking one of the links (bottom left) I'd like to reorder the elements, pulling the matched elements to the left of my container.

I do this by removing them from the DOM and shifting them to the top of the containing div. If you check your browser's console you'll see that this happens successfully, but the following call to Isotope (to redraw) fires the callback, but doesn't seem to trigger the actual redraw. Not entirely sure why this is the case, is anyone able to explain?

like image 784
purpletonic Avatar asked Nov 30 '22 02:11

purpletonic


1 Answers

Solved it:

$('#products').isotope( 'reloadItems' ).isotope( { sortBy: 'original-order' } );

or just:

$('#products').isotope( 'reloadItems' ).isotope();

Still not sure why reLayout doesn't trigger this behaviour though.

like image 57
purpletonic Avatar answered Dec 15 '22 09:12

purpletonic