This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge branch 'patch-3' of https://github.com/rstacruz/jquery.turbolinks

… into rstacruz-patch-3

Conflicts:
	README.md
  • Loading branch information...
2 parents ec0cdff + 008aba4 commit ef267e744771c32774e93cbb1f45da5526bcfb64 @kossnocorp committed Feb 1, 2013
Showing with 21 additions and 1 deletion.
  1. +21 −1 README.md
View
@@ -6,7 +6,7 @@ But if you have a large codebase with lots of `$(el).bind(...)` Turbolinks will
I wrote jquery.turbolinks to solve this problem in [my project](http://amplifr.com). 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](http://evilmartians.com/).
+Initially sponsored by [Evil Martians](http://evilmartians.com/).
This project is a member of the [OSS Manifesto](http://ossmanifesto.org/).
@@ -46,6 +46,26 @@ If you want to change default behaviour you can use `$.setFetchEvent`:
$.setReadyEvent('custom_loading_event');
```
+## Troubleshooting
+
+### Events firing twice or more
+
+If you find that some events are being fired multiple times after using jQuery Turbolinks, you may have been binding your `document` events inside a `$(function())` block. For instance, this example below can be a common occurrence and should be avoided:
+
+``` javascript
+/* BAD: don't bind 'document' events while inside $()! */
+$(function() {
+ $(document).on('click', 'button', function() { ... })
+});
+```
+
+You should be binding your events outside a `$(function())` block. This will ensure that your events will only ever be bound once.
+
+``` javascript
+/* Good: events are bound outside a $() wrapper. */
+$(document).on('click', 'button', function() { ... })
+```
+
## Changelog
This project uses [Semantic Versioning](http://semver.org/) for release numbering.

0 comments on commit ef267e7

Please sign in to comment.