根据文档,我在使用多页对话框时遇到了问题。我遇到一个问题,在初次访问具有对话框(多页)的页面时,单击打开对话框的按钮,它不起作用。但是,如果我随后刷新页面,然后再次单击该按钮,对话框就会正常显示。这发生在所有设备上。
有什么想法可以从哪里开始?我检查了代码验证,唯一缺少的是某些图像上的一些 alt 标签。
这是一个链接:
点击画廊然后“浏览画廊”
更新 1
我发现了一个有趣的结果。如果我通过链接从另一个页面访问该页面(即:从主页转到图库),该对话框将不起作用。但是,如果我通过网络浏览器地址栏直接转到 url,它确实有效。因此,它与推荐和可能的 ajax 页面加载有关。
最佳答案
我想通了。我越来越深入地阅读文档,并在 http://jquerymobile.com/demos/1.0a4.1/docs/pages/docs-pages.html 上偶然发现了这一段。 :
It's important to note 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.
For example, a link to a page containing multiple internal pages would look like this: Multi-page link
当我将 rel 添加到推荐链接时,它起作用了。欢乐时光。
关于javascript - jquery 移动对话框不会在第一页加载时打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8965286/