将表单插入页面后重新初始化 jquery-mobile [英] Reinitialize jquery-mobile after inserting a form into the page

查看:22
本文介绍了将表单插入页面后重新初始化 jquery-mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 ajax 动态地将表单插入到页面中.将其插入 dom 树后,我想重新初始化 jquery mobile 以设置表单的样式.我查看了 http://jquerymobile.com/test/docs/api/events.html 但由于文档对 jquery mobile 没有帮助,我无法找到正确的事件.

I'm inserting a form via ajax dynamically into the page. After inserting it into the dom tree, i would like to reinitialize the jquery mobile to style the form. I had a look into http://jquerymobile.com/test/docs/api/events.html but since the documentation is pretty unhelpful for jquery mobile I'm not able to find the correct event.

推荐答案

将表单添加到 DOM 后,使用 .trigger('create'); 在表单上初始化任何小部件(表单元素)您刚刚添加:

After you have added the form to the DOM, use .trigger('create'); on the form to initialize any widgets (form elements) you've just added:

...html('<form><input data-role="slider" type="text" /><input type="button" value="button" /></form>').trigger('create');

这是一个演示:http://jsfiddle.net/TBRXk/

这篇关于将表单插入页面后重新初始化 jquery-mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆