Skip to content
Advertisement

Twitter Bootstrap tab shown event not firing on page load

In a page where I have n tabs, and the following script (coffeescript, I checked the compiled javascript and it seems to be ok)…

JavaScript

Now, the ‘shown’ event does not fire on page load, so for the first tab being shown on the page there’s no way to handle this (ie: loading content via xhr)

I tried adding this to the above script, to see if triggering it manually could work:

JavaScript

… but it didn’t.

This is the HTML code I use in my view

JavaScript

Any clue?

Advertisement

Answer

Try leaving the class active off both the tab <li> and the content <div>. One of the first lines of code in the show() method is to short-circuit if the tab being requested is already active.

JSFiddle

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement