Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Error in jQuery document ready handler in Rails 4 #26

nickurban opened this Issue · 7 comments

4 participants


This worked fine in Rails 3.2. I'm updating to Rails 4 and experiencing an error in my document ready handlers. If I remove jquery.turbolinks from my application.js, the error goes away.

behavior.js is a file with a declaration like this:

jQuery(function($) {

On page load, I get the following error:

Uncaught TypeError: object is not a function behavior.js?body=1:2
(anonymous function) behavior.js?body=1:2
jQuery.event.dispatch jquery.js?body=1:5096
elemData.handle jquery.js?body=1:4767
jQuery.event.trigger jquery.js?body=1:5008
(anonymous function) jquery.js?body=1:5692
jQuery.extend.each jquery.js?body=1:658
jQuery.fn.jQuery.each jquery.js?body=1:267
jQuery.fn.extend.trigger jquery.js?body=1:5691
$.turbo.onLoad jquery.turbolinks.js?body=1:33
fire jquery.js?body=1:3049
self.fireWith jquery.js?body=1:3161
jQuery.extend.ready jquery.js?body=1:434
completed jquery.js?body=1:105

I downgraded to 1.0 and it's working again, so this seems like a 2.0 problem.


Oh man, seems like jQuery(function($) { .. }) isn't working anymore as part of the move to use jQuery's own triggering mechanism for 2.0.

@rstacruz rstacruz closed this in 41953e7

Just issued a fix. See if this helps—it should now work as expected.

For now, you'll need to upgrade to the latest unreleased version to try it out.

gem 'jquery-turbolinks', github: 'kossnocorp/jquery.turbolinks'
$ bundle update jquery-turbolinks

Thanks, that seems to work.


@kossnocorp I've bumped to v2.0.1 (and even drafted a release in /releases) — feel free to rake release whenever :)


@rstacruz thanks!



That didn't work for me, still have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.