Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

jQuery plugin for drop-in fix binded events problem caused by Turbolinks

tree: a608907095

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 src
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CONTRIBUTING.md Add contributing guidelines November 30, 2012
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Guardfile Add guard file October 02, 2012
Octocat-spinner-32 LICENSE.md Add dummy README and LICENSE docs October 02, 2012
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 jquery-turbolinks.gemspec Depends on railties instead of rails December 18, 2012
Octocat-spinner-32 package.json
README.md

jQuery Turbolinks

Do you like Turbolinks? It's easy and fast way to improve user experience of surfing on your website.

But if you have a large codebase with lots of $(el).bind(...) Turbolinks will surprise you. Most part of your JavaScripts will stop working in usual way. It's because the nodes on which you bind events no longer exist.

I wrote jquery.turbolinks to solve this problem in my project. It's easy to use: just require it immediately after jquery.js. Your other scripts should be loaded after jquery.turbolinks.js, and turbolinks.js should be after your other scripts.

Sponsored by Evil Martians.

This project is a member of the OSS Manifesto.

Usage

Gemfile:

gem 'jquery-turbolinks'

JavaScript manifest file:

//= require jquery.turbolinks

And it just works!

$.setReadyEvent

By default ready function is bound to page:load event.

If you want to change it use $.setReadyEvent function:

$.setReadyEvent('page:change');

$.setFetchEvent

By default right after trigger page:fetch $.isReady is set to false. And after page:load is set to true.

If you want to change default behaviour you can use $.setFetchEvent:

$.setReadyEvent('custom_loading_event');

Changelog

This project uses Semantic Versioning for release numbering.

1.0.0-rc1 (November 28, 2012)

  • Set $.isReady to false after page:fetch #6;
  • add $.setFetchEvent function;
  • remove all delegated events after trigger fetch event #8.

1.0.0-rc (November 8, 2012)

  • Add turbolinks as dependency (kudos to @gbchaosmaster);
  • run callback after adding to waiting list if $.isReady #6.

0.2.1 (October 15, 2012)

  • Pass jQuery object to each callback #4

0.2.0 (October 10, 2012)

  • Change event: page:change -> page:load (kudos to @davydotcom);
  • added ability to change ready event via $.setReadyEvent

0.1.0 (October 3, 2012)

  • First, initial release

Contributors

Idea and code by @kossnocorp.

The MIT License

Something went wrong with that request. Please try again.