Reputation: 155
I am doing an only front end project with backbone. And at one point I want to do the following :
The problem is that I don't have any backend so I never save the inputs of the user, How can I change the view and still have the data of the form?
I was thinking about storing it temporary into localstorage but it's not really a good solution for perfs...
Thanks
Upvotes: 0
Views: 895
Reputation: 1
Im also doing an one view web app with backbone.
I think the point of your problem is you really has only one page but load different views into this page. Not change to another page.
I suppose your app url is http://xxx.xxx.xxx/#first_view. and use backbone Router to change views
window.location = Global.getBaseURL() + "#second_view" to change your view. And you actually load the "second_view" by ajax and put html into current page. You never lose your js variable.
Upvotes: 0
Reputation: 146164
view.on('formComplete', this.storeModel)
this.emit('formComplete', this.model);
)storeModel
handler function takes the same model instance, stores it as this.model
temporarily on the router, and then navigates to the graph view.this.model
it to the graph view contsructor options, render, attachThis is sort of using your router as an in-memory data cache, but since you have no back end, you need to store data somewhere.
Upvotes: 1