-
-
Save hiroprotagonist/921920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// force certain pages to be refreshed every time. mark such pages with | |
// 'data-cache="never"' | |
// | |
jQuery('div').live('pagehide', function(event, ui){ | |
var page = jQuery(event.target); | |
if(page.attr('data-cache') == 'never'){ | |
page.remove(); | |
}; | |
}); | |
// for pages marked with 'data-cache="never"' manually add a back button since | |
// JQM doesn't. this is *okay* because we know the browswer history stack is | |
// intact and goes to the correct 'back' location. | |
// specified back button - however! | |
// | |
jQuery('div').live('pagebeforecreate', function(event, ui){ | |
var page = jQuery(event.target); | |
if(page.attr('data-cache') == 'never'){ | |
var header = page.find('[data-role="header"]'); | |
if(header.jqmData( "backbtn" ) !== false && header.find('[data-rel="back"]').size() == 0){ | |
var back = jQuery('<a href="#" data-icon="back" data-rel="back">Back</a>'); | |
header.prepend(back); | |
}; | |
}; | |
}); |
Thanks,
I finally got it working and it was a different approach, maybe because I am actually submitting a form (with a button, not link). The page attribute does not work.
I got it working by including the data-ajax="false" into the
tag... May not be the best approach, but it is what I need now (specially under development).Cheers,
Howdy hiroprotagonist,
I've tried adding data-dom-cache and it's not working...jQM 1.2...any ideas?
I've tried adding data-dom-cache to the page I wish to cache....is the following example correct usage?
Much Thanks!
EX.
<div data-role="header" data-theme="a">
<h1>Search</h1>
<a href="../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
</div>
<div data-role="content"> ...
I have javascript functions that just run when the page loads, if I run "jqm-data-cache-never" it will remove that orignal page and all the javascript functions that can run, I tried putting the js functions in different on() calls that jQM offers but never seen a result that works,
Any ideas?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, there is a new attribute called "data-dom-cache" which can be true or false. You can use it on pages, dialogs and links. this could be what ur looking for. see the docs:http://jquerymobile.com/demos/1.1.0/docs/api/data-attributes.html .
Once i've suggested to use cache-control properties from the http response header which i think is much more smart but the developers rejected. Let me please know if data-dom-cache is working for you.