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);
};
};
});
@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