微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – jquery mobile – 附加html内容并应用JQuery mobile的样式

我有一个移动网站,它是通过附加XML Feed中的数据创建的.最初加载Feed及其所有数据,然后在用户浏览网站时从阵列中获取正确的Feed内容.之前的内容将从div中清除,并应用新内容.我试图在添加内容时,将某种update()函数调用到jquery mobile,以便它更新哈希值,应用适当的类等,但我似乎无法在文档中找到它.我在这里阅读这篇文章

Dynamically creating jQuery Mobile pages using jQuery Templates

但我找不到任何地方记录的page()函数,它似乎对我不起作用.任何想法如何实现这一目标?

解决方法:

看看latest documentation and demos page

Enhancing new markup
The page plugin dispatches a “pagecreate”
event, which most widgets use to auto-initialize themselves. As long
as a widget plugin script is referenced, it will automatically enhance
any instances of the widgets it finds on the page.

However, if you generate new markup client-side or load in content via
Ajax and inject it into a page, you can trigger the create event to
handle the auto-initialization for all the plugins contained within
the new markup. This can be triggered on any element (even the page
div itself), saving you the task of manually initializing each plugin
(listview button, select, etc.).

For example, if a block of HTML markup (say a login form) was loaded
in through Ajax, trigger the create event to automatically transform
all the widgets it contains (inputs and buttons in this case) into the
enhanced versions. The code for this scenario would be:

$( ...new markup that contains widgets... ).appendTo( ".ui-page").trigger( "create" );

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐