Reputation: 136
I have this small function to reload an isotope layout inside Bootstrap tabs when they're activated (taken from this question)
jQuery(document).ready(function($){
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
alert("Somethings happening");
$('.b5-file-manager.b5-list').isotope('layout');
});
});
Initially this solution wasn't working for me, but after using a few different selectors to narrow down my targeting (and try and make sure nothing funny was going on) this then began to work. I deleted the alert, as my script was now working, but then the layout
stopped firing.
This is in use in a WordPress child theme, but is enqueued correctly in the child theme functions.php, and is loading in the page OK. I think it may be something to do with when the script loads as it was working. I have an example page here in my test build (sorry, I know this isn't good SO practice, but its the best place to see it an action)
Thanks for any assistance.
Upvotes: 0
Views: 62
Reputation: 187
The quotes around tab may be causing the issue. Try this:
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
Upvotes: 0
Reputation: 74738
There might be some error about $
.
Wrap your code in IIFE syntax:
(function($){
//put all code here
})(jQuery);
Upvotes: 1