如何在jQuery Mobile UI中禁用缓存

问题描述:

尝试...

<div data-role="page" data-cache="30"> 
<div data-role="page" data-cache="never">
<div data-role="page" data-cache="false"> 
<div data-role="page" cache="false">

没有什么可以工作......所以目前我正在解决服务器上的问题 - 通过......

Nothing seemes to work... so at the moment I'm fixing the problem on the server-side via...

.'?x='.rand()
.'&x='.rand()

我不想仅仅通过缓存来禁用AJAX。必须有更好的方法......我错过了什么吗?

I don't want to disable the AJAX just the caching. There has to be a better way though... am I missing something?

谢谢,

Serhiy

谢谢你们的答案,尽管他们对我不起作用,但他们确实指出了我的方向找到我要找的代码。

Thank you for the answers guys, and even though they didn't quite work for me they did point me in the direction to find the code I was looking for.

这是我在这位绅士的Github Gist上找到的代码。

This is the code that I found on this gentleman's Github Gist.

https://gist.github.com/921920

jQuery('div').live('pagehide', function(event, ui){
  var page = jQuery(event.target);

  if(page.attr('data-cache') == 'never'){
    page.remove();
  };
});

该Gist中还有一个后退按钮代码,但我似乎并不需要它因为我的后退按钮似乎工作得很好......

There is also a back button code in that Gist, but I don't seem to need it really as my back button seems to work just fine...