Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hiroprotagonist/921920 to your computer and use it in GitHub Desktop.
Save hiroprotagonist/921920 to your computer and use it in GitHub Desktop.
// 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);
};
};
});
@brunobraga
Copy link

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,

@Rezu
Copy link

Rezu commented Feb 20, 2013

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">   ...

@markthepixel
Copy link

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