Bootstrap radio-buttons toggle issue

JavascriptJqueryTwitter BootstrapRadio Button

Javascript Problem Overview


I'm trying to turn some regular buttons in radio buttons the twitter bootstrap way (http://twitter.github.com/bootstrap/javascript.html#buttons).

I followed the instructions, but when I press the buttons I get the following error in the console:

Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'toggle' .

Do you know what might cause it? The buttons are loaded in the page and only become visible when the corresponding content is displayed by AJAX.

Thanks!

Javascript Solutions


Solution 1 - Javascript

I had the same problem and it was driving me mad!!!!

Until I found that I was loading bootstrap before jqueryui...

I switched the order and notice that if I load jqueryui BEFORE bootstrap, I have no such problem :)

Solution 2 - Javascript

THis issue is due to jquery-ui blocking the initialization of Button definitions from bootstrap for users like me who have problems with shifting the order of the javascript file calls for instance when using the CJUiAutocomplete widget in Yii, just shift the javascript corresponding to button.js from the bootstrap file to the main working file and it will work smoothly.

Alternatively take the corresponding js and place it in a separate file that is called at the bottom of your javascript file stack.

Solution 3 - Javascript

Swapping the load order of Bootstrap and jQueryUI solves this problem but then it causes other issues like the Close X on jQueryUI dialogs fails to display. Is there another way to resolve this?

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
QuestionBogz902View Question on Stackoverflow
Solution 1 - JavascriptAlexandre PauloView Answer on Stackoverflow
Solution 2 - JavascriptRohanView Answer on Stackoverflow
Solution 3 - JavascriptConnie DeCinkoView Answer on Stackoverflow