Permalink
Browse files

Drop $.isReady to false after page:fetch (closes #6)

  • Loading branch information...
1 parent 8a78121 commit e4198b31ea9e390a7f03d31a8a18312292bb7675 @kossnocorp committed Nov 28, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/jquery.turbolinks.coffee
@@ -17,6 +17,15 @@ callbacks = []
ready = ->
callback($) for callback in callbacks
+# Turbolinks ready event
+turbolinksReady = ->
+ $.isReady = true
+ ready()
+
+# Turbolinks fetch:start handler
+fetchStart = ->
+ $.isReady = false
+
# Bind `ready` to DOM ready event
$(ready)
@@ -29,7 +38,10 @@ $.fn.ready = (callback) ->
$.setReadyEvent = (event) ->
$(document)
.off('.turbolinks')
- .on(event + '.turbolinks', ready)
+ .on(event + '.turbolinks', turbolinksReady)
# Bind `ready` to Tubolinks page load event
$.setReadyEvent('page:load')
+
+# After page load
+$(document).on('page:fetch', fetchStart)

0 comments on commit e4198b3

Please sign in to comment.