Created
June 22, 2013 17:35
-
-
Save eljojo/5841733 to your computer and use it in GitHub Desktop.
Patch to enable some basic debugging in turbolinks. Apply on commit https://github.com/rails/turbolinks/commit/bacde87fa141894d64970a6c825af5881d85d5dd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/assets/javascripts/turbolinks.js.coffee b/lib/assets/javascripts/turbolinks.js.coffee | |
index 4f59e37..d1d0640 100644 | |
--- a/lib/assets/javascripts/turbolinks.js.coffee | |
+++ b/lib/assets/javascripts/turbolinks.js.coffee | |
@@ -137,6 +137,7 @@ removeHash = (url) -> | |
link.href.replace link.hash, '' | |
triggerEvent = (name) -> | |
+ console.log 'trigering event', name | |
event = document.createEvent 'Events' | |
event.initEvent name, true, true | |
document.dispatchEvent event | |
@@ -271,8 +272,11 @@ ignoreClick = (event, link) -> | |
initializeTurbolinks = -> | |
+ console.log 'initializeTurbolinks' | |
document.addEventListener 'click', installClickHandlerLast, true | |
window.addEventListener 'popstate', (event) -> | |
+ console.log 'popstate triggered!', event.state?.turbolinks | |
+ console.log 'turbolinks initialized?', initialized | |
fetchHistory event.state if event.state?.turbolinks | |
, false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've a gist here for Turbolinks 5 to catch all events: https://gist.github.com/schmijos/12090ed79932993b40d90bfce70eed4a