Fixing “cannot call methods on button prior to initialization” when using Bootstrap

Ran into this problem today. I wanted to make a button with loading state and whenever I called

$().button('loading')

I got this error “cannot call methods on button prior to initialization; attempted to call method ‘loading'”.

Well, in my case, the fix was simple, just make sure to load jQueryUI before the bootstrap javascript file.

6 Comments

  1. Thank you so much for this tip! Saved me a lot of time.

  2. Francois Botha September 16, 2014 Reply

    Why?

    I mean… what is jQueryUI doing that it should be loaded first?

  3. Just wanted to say thank you! Saved my bacon.

  4. Marc Nolte October 8, 2014 Reply

    My hero!

    I’m curious like Francois Botha, could you elaborate on why?

    • Author

      I think it’s because both jqueryui and bootstrap have methods named “button”. Didn’t investigate further.

Leave a Comment

Your email address will not be published. Required fields are marked *

*