Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Backbone.history to go back

Tags:

backbone.js

I have inherited a half-finished mobile app built using Backbone.js (which I have never used).

I need, quite simply, to send the user back when they click a back button.

Some brief research leads me to believe it has something to do with Backbone.history but I can't figure out what.

Any ideas?

like image 841
hamishtaplin Avatar asked Oct 11 '11 20:10

hamishtaplin


People also ask

How to manipulate backbonejs-history?

This is the only method which can be used to manipulate the BackboneJS-History. It starts listening to routes and manages the history for bookmarkable URL's. options − The options include the parameters such as pushState and hashChange used with history. Save the above code in the start.htm file.

How to use the back () method in the history list?

The back () method loads the previous URL in the history list. This is the same as clicking the "Back button" in your browser. Note: This method will not work if the previous page does not exist in the history list. Tip: To load the next URL in the history list, use the history.forward () method.

How do I back a page in the history list?

The back() method loads the previous URL in the history list. This is the same as clicking the "Back button" in your browser, or history.go(-1). Note: This method will not work if the previous page does not exist in the history list. Tip: To load the next URL in the history list, use the history.forward() method.

What is the use of history back method in Salesforce?

History back () Method 1 Definition and Usage. The back () method loads the previous URL in the history list. This is the same as clicking the "Back button" in your browser. 2 Browser Support 3 Technical Details


2 Answers

Unless the app uses the fancy-schmancy HTML5 pushState events, I don't see a need for Backbone.History here. Just use window.history.back().

like image 168
Matt Ball Avatar answered Oct 07 '22 10:10

Matt Ball


Nowadays you can also use some more Backbone with Backbone.history.history which provides you methods like .forward, .go and finally Backbone.history.history.back().

like image 39
Miguelgraz Avatar answered Oct 07 '22 09:10

Miguelgraz