How to change page in jQuery mobile (1.4 beta)?

假装没事ソ 提交于 2019-11-26 01:59:31

问题


I am reading the docs that $.mobile.changePage has been deprecated.

But it doesn\'t say in favor of what, or what can I use instead.

Is there a new API documentation page for this?

I used to use $.mobile.changePage(\"index.html\", {reloadPage:true}); but it seems that adding reloadPage:true the page breaks


回答1:


As of jQuery Mobile 1.4, $.mobile.changePage() is deprecated and replaced with:

$(":mobile-pagecontainer").pagecontainer("change", "target", { options });

Shortened...

$.mobile.pageContainer.pagecontainer("change", "target", { options });

Even shorter...(1)

$("body").pagecontainer("change", "target", { options });

Note: target is #page_id or URL.

Demo


(1)<body> is pageContainer by default, unless $.mobile.pageContainer is modified on mobileinit.




回答2:


This works for me:

$.mobile.pageContainer.pagecontainer('change', nextPage, {
  transition: 'flow',
  reload    : true
});

nextpage: is URL to the nextpage example (var nextPage = 'nextPage.html')



来源:https://stackoverflow.com/questions/19174611/how-to-change-page-in-jquery-mobile-1-4-beta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!