Reputation: 56
I want to remove a page element (data-role="page") in a jQuery mobile multi-page DOM when returning from it (going back). I can use the pagehide event, but that triggers also when going forward. Any suggestions?
Upvotes: 2
Views: 180
Reputation: 13620
I think jquery mobile beta 2 does it for you by default.
From beta 2 release notes:
For Beta 2, we added a simple mechanism to keep the DOM tidy. It works like this: whenever a page is loaded in via Ajax, it is flagged for removal from the DOM once you navigate away to another page (technically, on pagehide). If you return to a deleted page, the browser may be able to retrieve the file from it’s cache, or it will re-request it fro the sever if needed.
More info here - http://jquerymobile.com/blog/2011/08/03/jquery-mobile-beta-2-released/
Upvotes: 1