2012-05-14 53 views
1

好吧,这很奇怪: 首先我打开page1.html。从page1.html我通过链接转到page2.html,然后通过另一个链接转回到page1.html。这些链接只是相对路径的正规链接而不是rel="back"种链接。jQuery Mobile没有正确地重新加载我的页面

问题是:jQuery Mobile的将缓存page1.html(尽管它不缓存page2.html) 如果我添加的rel =“外在”到page2.html的链接,然后在第1页的刷新,但综合起来,所有的资源也重新加载(这不是我想要的)。

我只想要重新加载page1.html的html。我将data-cache=falsedata-dom-cache=false添加到了page1.html注释中,但它没有帮助。

如何让jQuery Mobile不缓存page1.html给定的场景?

回答

1

我正在使用基于data-dom-cache属性手动删除页面的workarround。您需要添加的事件处理程序pagehide事件并检查页面数据的domCache财产

$(document).on('pagehide', function(event, ui){ 
      var page = $(event.target); 
      var pageData = page.data(); // get all the data attributes (remove the data prefix and format to camel case) 
      if(pageData.domCache == false){ 
       console.log("Removing Page (id: " + page.attr('id') + ", url: " + pageData.url + ")"); //Log to console for debugging 
       page.remove(); // remove the page 
     } 
    }); 
+0

感谢了很多,它的伟大工程。我想知道为什么这个功能没有默认包含在内...... – viniciusnz

相关问题