将表单插入页面后,重新初始化jquery-mobile [英] Reinitialize jquery-mobile after inserting a form into the page
本文介绍了将表单插入页面后,重新初始化jquery-mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
将表单添加到DOM之后,使用表单上的 .trigger('create');
来初始化刚添加的任何窗口小部件(窗体元素):
... html('< form>< input data-role =slidertype =text >< input type =buttonvalue =button/></form>').trigger('create');
这是一个演示: http://jsfiddle.net/TBRXk/
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.
解决方案
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');
Here is a demo: http://jsfiddle.net/TBRXk/
这篇关于将表单插入页面后,重新初始化jquery-mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文