jquery - 在 jquery mobile 中加载多页文件

标签 jquery html ios ajax jquery-mobile

我有两个单独的 html 文件,它们正在使用 jquery/jquery 移动框架通过 ajax 加载。但是当我加载第二个文件时,它只加载第一个div的页面角色。有什么办法可以解决这个问题吗?

最佳答案

这是设计使然。当 linking a multipage document use rel="external" or data-ajax="false"

It's important to note that if you are linking from a mobile page that was loaded via Ajax to a page that contains multiple internal pages, you need to add a rel="external" or data-ajax="false" to the link. This tells the framework to do a full page reload to clear out the Ajax hash in the URL. This is critical because Ajax pages use the hash (#) to track the Ajax history, while multiple internal pages use the hash to indicate internal pages so there will be conflicts in the hash between these two modes.

<a href="multipage.html" rel="external">Multi-page link</a>

如果以编程方式更改页面,请使用

$.mobile.ajaxEnabled = false;
$.mobile.changePage("multipage.html");

关于jquery - 在 jquery mobile 中加载多页文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14759317/

相关文章:

jquery - 如何编辑DataTable()打印标题

javascript - 我已经构建了自动完成输入框(但是foucsout有问题)

javascript - 是否可以找到元素的父元素然后导航 DOM?

javascript - 缩放背景图像以适合 ie8 窗口

ios - CloudKit iOS 如何设置世界写入权限

objective-c - 在 Objective-C 中将八进制字符串转换为十进制?

具有以下内容的 jQuery 动画高度

asp.net - HTML 标记中 gridview 中 BoundField 的自定义消息

html - 具有多个跨度的文本溢出省略号

ios - 如何调整 UIButton 中文本的字体大小以在 Swift 中以编程方式适应宽度?