Do any events get fired when you return to a page via the back button? I have a page where a user can select from several checkboxes. Each checkbox checked generates a dynamically created button on the page. When I navigate to the next page and hit the back button the checkboxes are still checked but my dynamically created buttons are gone. Can this be fixed?
Asked
Active
Viewed 305 times
0
-
You could 'onready' check the presence of the checkboxes and generates the respective buttons. – Davide Pastore Oct 21 '14 at 14:54
-
It doesn't need fixing. The checkboxes are not being clicked or changed - the initial value is what it previously was. So, your event handlers are not triggering. Write a generic function that checks the state of all of them and does what it needs to do, then you can call that when any of them change, but also at document ready. – Reinstate Monica Cellio Oct 21 '14 at 14:54
-
The feature of "memorising" form history varies depending on the browser, I believe. You might also like to check out: http://benalman.com/projects/jquery-bbq-plugin/ – rybo111 Oct 21 '14 at 15:00
-
If I print something to the console 'onready' it gets printed when I hit the back button but no other code gets executed. – Mike Glaz Oct 21 '14 at 15:28
1 Answers
0
To work with back button, you need to understand, what page navigation means. When back button is pressed, browser navigates to previous location in history. They are called browser states.
You can achieve your goal, if you make changes in browser states, thus creating stateful application and using back button, user will be returned in some place in history.
There are couple JavaScript libraries, that allow easier access to history management features, but I will suggest only couple: BBQ, History.js, Hash.js, jQuery hashchange, Sammy.js, PathJS.