Browse files

Merge pull request #193 from benweint/add-page-received

  • Loading branch information...
2 parents 61e92f5 + e74ed4b commit 7d4238f2deafbccc8e40be07ef7d2197890ec941 @reed reed committed Mar 18, 2013
Showing with 3 additions and 0 deletions.
  1. +1 −0
  2. +2 −0 lib/assets/javascripts/
@@ -33,6 +33,7 @@ Since pages will change without a full reload with Turbolinks, you can't by defa
* `page:load` fetched page is being retrieved fresh from the server.
* `page:restore` fetched page is being retrieved from the 10-slot client-side cache.
* `page:change` page has changed to the newly fetched version.
+* `page:receive` page has been fetched from the server, but not yet parsed.
So if you wanted to have a client-side spinner, you could listen for `page:fetch` to start it and `page:change` to stop it. If you have DOM transformation that are not idempotent (the best way), you can hook them to happen only on `page:load` instead of `page:change` (as that would run them again on the cached pages).
2 lib/assets/javascripts/
@@ -29,6 +29,8 @@ fetchReplacement = (url) ->
xhr.setRequestHeader 'X-XHR-Referer', referer
xhr.onload = =>
+ triggerEvent 'page:receive'
if invalidContent(xhr) or assetsChanged (doc = createDocument xhr.responseText)

0 comments on commit 7d4238f

Please sign in to comment.