如何在 jQuery mobile (1.4 beta) 中更改页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19174611/
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
How to change page in jQuery mobile (1.4 beta)?
提问by Patrioticcow
I am reading the docs that $.mobile.changePage
has been deprecated.
我正在阅读$.mobile.changePage
已弃用的文档。
But it doesn't say in favor of what, or what can I use instead.
但它并没有说支持什么,或者我可以用什么来代替。
Is there a new API documentation page for this?
是否有新的 API 文档页面?
I used to use $.mobile.changePage("index.html", {reloadPage:true});
but it seems that adding reloadPage:true
the page breaks
我曾经使用过,$.mobile.changePage("index.html", {reloadPage:true});
但似乎添加reloadPage:true
了分页符
回答by Omar
As of jQuery Mobile 1.4, $.mobile.changePage()
is deprecated and replaced with:
从jQuery Mobile 1.4 开始,$.mobile.changePage()
已弃用并替换为:
$(":mobile-pagecontainer").pagecontainer("change", "target", { options });
Shortened...
缩短...
$.mobile.pageContainer.pagecontainer("change", "target", { options });
Even shorter...(1)
更短... (1)
$("body").pagecontainer("change", "target", { options });
Note:targetis #page_id or URL.
注意:目标是#page_id 或 URL。
(1)<body>
is pageContainerby default, unless $.mobile.pageContainer
is modified on mobileinit
.
(1)默认<body>
是pageContainer,除非$.mobile.pageContainer
在 上修改mobileinit
。
回答by Eagle_one
This works for me:
这对我有用:
$.mobile.pageContainer.pagecontainer('change', nextPage, {
transition: 'flow',
reload : true
});
nextpage: is URL to the nextpage example (var nextPage = 'nextPage.html')
nextpage: 是下一页示例的 URL (var nextPage = 'nextPage.html')