metafizzy / isotope

:revolving_hearts: Filter & sort magical layouts
https://isotope.metafizzy.co
11.04k stars 1.42k forks source link

Reload all instances of isotope #1419

Closed kromalski closed 6 years ago

kromalski commented 6 years ago

Hello, How can I reload/relayout all instances of the isotope.? I have jQuery tabs with isotope instance inside them (I don't know the number of the items) and I want to reinitialise them after tab switch. Is this possible?

desandro commented 6 years ago

Rather than re-initializing all of them, I think the better pattern would be initializing or laying out just the one that's visible. Best way to do this if if you Tab plugin provides an event with the selected tab.

Could you provide a reduced test case? See Submitting Issues in the contributing guidelines.

kromalski commented 6 years ago

Thanks for the reply! I solved this, it was related to bootstrap tabs more than on isotope itself:

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  $(this).closest('.cl_tabs').find('.tab-content .active').find('.shop-products').isotope( 'layout' );
});

Did the trick

desandro commented 6 years ago

Nice work! Thanks for following up