flyingarmadillo
flyingarmadillo

Reputation: 2139

twitter-bootstrap-rails Uncaught TypeError / $ is not a function

While developing a rails app, I was in the google chrome inspect element console testing an ajax link when all of the sudden I noticed 12 errors of the same kind:

Console log errors

I have no clue what is happening here, but my app works just fine regardless. However, When I pull my app up in firefox, my app does not even load. I get stopped and this error pops up:

Debug screen showing the error location

I dont even know what else to say here because I am completely stumped.

Upvotes: 3

Views: 2393

Answers (1)

flyingarmadillo
flyingarmadillo

Reputation: 2139

Ok, I found what was the problem was. When trying to get the bootstrap dropdown buttons to work the other day, I have rearranged the application.js folder to load bootstrap before jquery. I changed this:

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .

to this:

//= require twitter/bootstrap
//= require jquery
//= require jquery_ujs
//= require_tree .

At the time, this fixed the bootstrap dropdown problem. However, I now I realize that when bootstrap calls jquery, it will not have been loaded yet. Thus, the error $ function does not exist. Just changed the lines back to the proper order and all is now well.

Upvotes: 7

Related Questions