1

I am new to Backbone.js and was wondering how exactly I get history persistance working with Backbone.js, whether it is actually possible or whether I need to resort to History.js.

I am building a single-page web page that accesses Facebook's Graph API. Currently, I can map the right actions to the path's returned by the Backbone.History Object that get created by using the built in Router.navigate function.

However, those actions always require a new call to the API, since in the current implementation of the Router navigate function, there is no way to serialize the current data/state.

I was just wondering whether there is a way, or what common practice is.

nambrot
  • 2,551
  • 2
  • 19
  • 31
  • So, you're losing state when you're hash(or pushstate) changes? Where are you storing your state? code always helps :) – Chris Biscardi Dec 26 '11 at 03:25
  • I am not storing my state as fo right now since I dont know where I should do that. I am using Backbone.Router.navigate for the History right now – nambrot Dec 26 '11 at 03:27

2 Answers2

0

you should use hashurls if you have a single page website. And a javascript to check for change in hash that changes the page content accordingly. that way you dont rely on the browser state but on the basic URL history method as the browser remembers hash as seperate page without actual reload

Deept Raghav
  • 1,430
  • 13
  • 14
0

So for future reference If you want similar functionality to the HTML5 pushstate api, you probably want to use local or sessionStorage to save your state and then retrieve it properly

nambrot
  • 2,551
  • 2
  • 19
  • 31