Reputation: 11240
I'm using jquery mobile to make a basic html5 app. I am doing something where when you click a button, it adds new class to the body like this jsfiddle shows.
The issue with this however is that when the user clicks 'back' they are still left with the newly added class.
So the question / challenge is how does one remove the most recently added class if the back button is clicked? In other words, how can I make the back button trigger a function?
Upvotes: 1
Views: 317
Reputation: 7655
The only way is to bind a function to the BACK button.
I couldnt find a straight forward way for it. One of the hacks is to put a click event for all anchor tags and on click check if the grandchild span of the anchor tag has the innertext as "Done" or anything which u specify as
$.mobile.page.prototype.options.backBtnText = "Done";
Then u can remove the class there. However this is not a good way.
Do tell me if you find a cleaner solution.
Upvotes: 1