Jquery Document Ready / DOM Ready Problems

The regular way to tell jQuery to wait until the DOM is ready is:

jQuery ->

But this will not work in many cases in a Rails 4 app. The reason is that Turbolinks functionality is enabled by default. Instead of reloading the whole page when you navigate to a new page within your site, Turbolinks will only load the new content. The old content (your navigation bar, etc) will stay the same. So there never is a DOM ready event.

These two sites have notes about how to fix this:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s