The state of the foundation and history

Using the trunk, can you somehow store some data in history so that it can be restored when you call your back?

In no basic application, the application I will look as follows. When performing an action:

//When doing some action
history.pushState(mycurrentData, title, href)

and the following to return the current data in case of a return:

function popState(event) {  
    if (event.state) { 
        state = event.state;
        //get my data from state
    }
}
window.onpopstate = popState;

I need to apply the same behavior in my base application.

thank

+3
source share
1 answer

This is currently not possible using Backbone directly

http://backbonejs.org/docs/backbone.html#section-139

You can see a couple of lines at this point in the code:

window.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, frag);

So, he always sets the data to an empty object.

, - .

, Backbone, . :)

, - , : https://github.com/documentcloud/backbone/pull/660

+6

All Articles