From b731eebf0ce64cb100866b9a13538e504d680a21 Mon Sep 17 00:00:00 2001 From: onlymejosh Date: Wed, 14 Aug 2013 18:55:21 +0100 Subject: [PATCH] Update README.md for Turbolinks Changed the documentation so that Backbone.history is checked on page:change to see if it exists if it does it stops and starts it again, this solves the "Backbone History already started" --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25de09d..14d9167 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,13 @@ Edit your posts index view `app/views/posts/index.html.erb` with the following c $(function() { // Blog is the app name window.router = new Blog.Routers.PostsRouter({posts: <%= @posts.to_json.html_safe -%>}); - Backbone.history.start(); + if (!Backbone.History.started) { + Backbone.history.start(); + } + $(document).on("page:change", function(){ + Backbone.history.stop() + Backbone.history.start() + }) });