【问题标题】:jQuery Mobile - stop cachingjQuery Mobile - 停止缓存
【发布时间】:2013-02-19 06:49:15
【问题描述】:

在我的例子中,链接加载到一个特殊的 div 包装器中,这些包装器是其链接的父级。 我通过pageload 事件做到这一点。

当 JQuery Mobile 执行 AJAX 请求时一切正常。但是如果我点击访问过的链接,jquery mobile 不会发送请求,而是显示空白页,换句话说,从缓存中替换#page1 内容。

我需要这些请求。

UPD

事件pagebeforeloadpageload 不会出现在缓存案例中。 =\

【问题讨论】:

    标签: jquery jquery-mobile


    【解决方案1】:

    您可以像这样指定不缓存页面:

    <div data-role="page" id="page-detail" data-dom-cache="false">  
        ....
    </div>
    

    更新

    其实是data-dom-cache=false,可用于页面、链接和对话框

    文档http://jquerymobile.com/demos/1.2.0/docs/api/data-attributes.html

    如果您想避免对所有页面进行数据完善,请查看此处:How does one disable Caching in jQuery Mobile UI

    【讨论】:

      【解决方案2】:

      请咬我的代码

      $(document).on('pagebeforeload', function(event, data) {
          var url = data.url;
          if (url.toLowerCase().indexOf("office") >= 0) {
              event.preventDefault();
              $.get(data.absUrl, {}, function(res){
                  _this = $(res);
                  if (_this.attr('data-id')>0) { 
                      var card_id = _this.attr('data-id');
                      $('#detail-'+card_id).empty().append(_this).trigger('create');
                  }
              });
              data.deferred.reject( data.absUrl, data.options );
          }
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-10-19
        • 2017-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-12
        相关资源
        最近更新 更多