javascript jQuery Mobile 在 changePage 后刷新页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10587634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:22:39  来源:igfitidea点击:

jQuery Mobile refresh page after changePage

javascriptjqueryajaxmobilejquery-mobile

提问by HjalmarCarlson

Is there anyway to force a jQm page to reload once changePage is complete?

一旦changePage完成,是否有任何强制jQm页面重新加载?

I have a number of pages dynamically loaded into an array. All of the pages that are being loaded are a part of a list, for example "20 mobile apps of 2011". Users will need to have the ability to swipe left and right to navigate the pages.

我有许多页面动态加载到一个数组中。所有正在加载的页面都是列表的一部分,例如“2011 年的 20 个移动应用程序”。用户需要能够左右滑动来导航页面。

I've added the current code here: http://jsfiddle.net/cncpts/qMe6Z/2/

我在这里添加了当前代码:http: //jsfiddle.net/cncpts/qMe6Z/2/

Notice how the URL's are being pulled from the array. From this i'm able to pull the next URL and the previous URL but I am only able to navigate one page forward and one back.

请注意 URL 是如何从数组中提取的。从这里我可以拉下一个 URL 和上一个 URL,但我只能向前浏览一页和向后浏览一页。

You can test the page here by clicking then swiping the mouse left or right: http://www.cncpts.me/complex/swipe/index.php

您可以通过单击然后向左或向右滑动鼠标来测试页面:http: //www.cncpts.me/complex/swipe/index.php

Any ideas on how to get the URL's to refresh while maintaining the native JQM transitions.

关于如何在保持本机 JQM 转换的同时刷新 URL 的任何想法。

回答by frequent

Why don't you use the JQM pagaintion plugin? Should be exactly what you are looking for.

你为什么不使用JQM 分页插件?应该正是你正在寻找的。

If you want to change the URL you will have to set the changehashoption to true in order for it to change

如果要更改 URL,则必须将changehash选项设置为 true 才能更改

 $.mobile.changePage(next,{
      changeHash:true,
      reloadPage:true,
      dataUrl:next
      });

Here is the link to the demo

这是演示的链接