ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2019-06-10 05:21:39  阅读:203  来源: 互联网

标签:jquery javascript ajax xml 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" );

标签:jquery,javascript,ajax,xml,jquery-mobile
来源: https://codeday.me/bug/20190610/1209984.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有