0
votes

I'm on the latest version of Backbone (1.1.0) and Marionette (2.3.0).

I have a hook to initialize the router

App.on "start", ->
   if Backbone.history
      Backbone.history.start()

And when I change routes in my application I use

Backbone.history.navigate route, options

My problem right now is when I load my application and click on my links to route my to different routes, as soon as I press the back button then the on "start" event is triggered again which causes an error since Backbone.History is already initialized.

Why is on "start" triggered again when pressing back in the browser?

1
Hmm...can you share a fiddle that replicates your problem? - seebiscuit
With Marionette the application instance can perform routing. Something like: AppInstance.Router.navigate( route, { trigger: true } ); maybe that will work better? - stakolee
@Seebiscuit the project infra is pretty big but I can try to isolate the problem - user391986
@stakolee I did not know that thank you, I will try although it still makes me uncomfortable this other behavioral bug - user391986
ah! it seems like it has something to do with Rails or a Rails plugin because I just extracted the app outside of rails and that issue is not there anymore! These were the rails library I was using: js-routes, sass-rails, turbolinks. In fact I just saw another post about turbo links so that must be it! Thank you guys goddamnyouryan.com/blog/rails-4-turbolinks-and-backbone - user391986

1 Answers

0
votes

Rails turbolinks was the problem