jQuery Mobile:防止在历史记录上删除节点 [英] jQuery Mobile: Prevent node being deleted on history back

查看:73
本文介绍了jQuery Mobile:防止在历史记录上删除节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

$(function() {
  $(window).on("swipeleft", jqmForward).on("swiperight", jqmBack);
});

function jqmBack(e) {
  var prevpage = $('div.ui-page-active').prevAll('div[data-role="page"]');
  if (prevpage.length > 0)
    $.mobile.changePage($(prevpage[0]), { transition: "slide", reverse: true }, true, true);
}
function jqmForward(e) {
  var nextpage = $('div.ui-page-active').nextAll('div[data-role="page"]');
  if (nextpage.length > 0)
    $.mobile.changePage($(nextpage[0]), "slide", false, true);
}

但是前进功能永远不会起作用,因为当您返回时,显然jqm会删除最新的div.ui-page.

But the forward function never works because apparently jqm deletes the latest div.ui-page when you go back.

在意外向右滑动(即后退)后,有没有办法让div.ui-page继续前进?

Is there a way to keep the div.ui-page to let you go forward after you accidentally swipe right (ie. go back)?

我正在使用jQuery Mobile 1.4.0

推荐答案

解决方案是

$(function () {
  $.mobile.page.prototype.options.domCache = true;
});

(请参见在DOM中缓存页面).但这出现了另一个问题.

(see Caching pages in DOM). But that rises another problem.

这篇关于jQuery Mobile:防止在历史记录上删除节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆