Making a jQuery Isotope layout initialize inside a Bootstrap Tab

十年热恋 提交于 2019-12-02 10:54:06
Karine

You can use the event shown.bs.tab :

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  $container.isotope('layout');
});

This code will trigger layout for all tabs, so you can detect the tab with e.target, if e.target == your tab link to your isotope grid, then trigger layout. Hope it makes sense...

http://jsfiddle.net/Vc6Vk/1/

The answer by Karine is great but it might not work in recent versions because the method "reLayout" has been renamed to "layout".

So instead of

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  $('.grid').isotope('reLayout');
});

please use

 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  $('.grid').isotope('layout');
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!