Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
177
rated 0 times [  179] [ 2]  / answers: 1 / hits: 16662  / 12 Years ago, thu, april 19, 2012, 12:00:00

I am trying to find a way to detect when the user has pressed the back / forward button in their browser.



I am using backbone to handle routes, along with backbone to render my views.



The issue is I can not hook into this page change event from anywhere.



I tried putting a log in my initialize function for my views .. but it is not tripped when i use the back button.



I am really not sure how else to detect this page change.


More From » backbone.js

 Answers
48

You should use Backbone.Router and make sure that you don't forget about Backbone.history.start() when starting your application.



Some useful information can be found here and here



Actually the second link is not an article, but a blog. And the guy who wrote it really seems to know a lot about the topic.



UPD: The idea is that backbone's router fire binded methods when your url changing. So you just should put your logic to this method and this way you will able to track that. Maybe it's non very automatic way, and it will take to write some code but I think it should work.


[#86124] Wednesday, April 18, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sheylap

Total Points: 141
Total Questions: 99
Total Answers: 99

Location: Sint Maarten
Member since Tue, Mar 29, 2022
2 Years ago
;