load all “jquery mobile pages” within a html document fetched via ajax

老子叫甜甜 提交于 2019-12-23 02:33:09

问题


Please let me know how to load all the "pages" in a html document into the current page dom. I tried using $.mobile.loadPage, but only the first "page" of the document is loaded. I want to load all the "pages" in that html document.

While googling for this i found two plugins ToddThomson/jQuery-Mobile-Subpage-Widget and a multiview plugin. But i could not find the basic "how to use" section for these two plugins.

Is there any links which shows how to use these plugins.


回答1:


It can be done easily.

Lets say you have 2 html files. First one has a one jQM page and second html has two pages. Also lets say first html page is called test1.html and second one is called test2.html, test1.html is first page to open.

Only thing you need to do (to load every page from test2.html) is to add an attribute data-prefetch to a a tag link leading to the second page.

Here's an example:

<a href="test2.html" class="ui-btn-right" data-prefetch>Next</a>

If you wish, go to my profile and send me an email, and I will send you a working example.

Here you can find more about data prefetch in jQM: http://jquerymobile.com/test/docs/pages/page-cache.html

If you are changing your page with a changePage function you can still prefetch it with a :

pageContainerElement.page({ domCache: true });


来源:https://stackoverflow.com/questions/14015175/load-all-jquery-mobile-pages-within-a-html-document-fetched-via-ajax

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