I'm using isotope
to align a set of divs
that are placed into a bootstrap tab. The tab is filled dynamically through a backbone
view
.
Here is the code before the view fills the tab:
<div class="tab-pane" id="program">
</div>
no divs to align then. After the view has filled the tab, the element will be something like this:
<div class="tab-pane" id="program">
<div class="badge">
aleatory content here
</div>
<div class="badge">
aleatory content here
</div>
<div class="badge">
aleatory content here
</div>
...
</div>
the tab will be rendered, but another tab will be visible by default. So, to view the content of #program
I will have to click on the proper tab
that opens my div#program
.
So, if I run this piece of code after rendering the div#program
:
this.$('#program div.muse-events').isotope({
itemSelector : 'div.badge'
,layoutMode : 'fitRows'
});
what I get is an EMPTY TAB. I personally think it's because some reference is missing and isotope
only removes the elements in the div#program
without handling the div#badge
.
If I want to get what I want, I have to call the piece of code above only when the tab is clicked (and hence the div#program
is showed and not hidden).
So, two questions:
- why is that? Is maybe the tab removed from the DOM until someone explicitly requests it?
- What's the best practice in this case? Is calling that command ok when I click the proper tab? Could I run it in some way when I call my
View.render
? It could be semantically much more correct
Thanks