Bootstrap: 'TypeError undefined is not a function'/'has no method 'tab'' when using bootstrap-tabs

JavascriptJqueryRuby on-RailsTwitter Bootstrap

Javascript Problem Overview


I'm building a little site at the moment and wanted to use some of the Bootstrap parts from Initialzr, specifically the tabs. I've currently tried using the example code provided by the Bootstrap project (http://twitter.github.com/bootstrap/javascript.html#tabs) and a few tweaks but get 'undefined is not a function' on load.

The JS files are preloaded in the right order (jQuery, libs/bootstrap/*, my script.js file/the script mixed in the html), standard jQuery commands (hide etc) all work fine so it doesn't appear to be related to the noConflict() option.

What else do I need to check?

Javascript Solutions


Solution 1 - Javascript

This can also be caused if you include bootstrap.js before jquery.js.

Others might have the same problem I did.

Include jQuery before bootstrap.

Solution 2 - Javascript

I actually managed to work out what I was doing wrong (and it was my fault).

I'm used to using pre-jQuery Rails, so when I included the Bootstrap JS files I didn't think that including the version of jQuery bundled with them would cause any issues, however when I removed that one JS file everything started working perfectly.

Lesson learnt, triple check which JS files are loaded, see if there's any conflicts.

Solution 3 - Javascript

make sure you're using the newest jquery, and problem solved

I met this problem with this code:

<script src="/scripts/plugins/jquery/jquery-1.6.2.min.js"> </script>
<script src="/scripts/plugins/bootstrap/js/bootstrap.js"></script>

After change it to this:

<script src="/scripts/plugins/jquery/jquery-1.7.2.min.js"> </script>
<script src="/scripts/plugins/bootstrap/js/bootstrap.js"></script>

It works fine

Solution 4 - Javascript

Probably is the use of the "on" event that Bootstrap use a lot and was inserted at jQuery 1.7 http://api.jquery.com/on/

Solution 5 - Javascript

We can try by using latest jQuery library. I got the same issue. I used jQuery-1.4.2.min before and getting the error. After that I used version 1.9.1 and it works. Thanks

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNicholas SmithView Question on Stackoverflow
Solution 1 - JavascriptAlan WhitelawView Answer on Stackoverflow
Solution 2 - JavascriptNicholas SmithView Answer on Stackoverflow
Solution 3 - JavascriptJohnny ZhaoView Answer on Stackoverflow
Solution 4 - JavascriptAlexandre Magno Teles ZimererView Answer on Stackoverflow
Solution 5 - Javascriptuser1996803View Answer on Stackoverflow