插入一个表格到页面重新初始化的jQuery移动后,初始化、表格、页面、jQuery

2023-09-11 00:35:18 作者:好听诗意的长

我通过AJAX动态插入一个表格到页面。将其插入到DOM树后,我想重新初始化jQuery Mobile的样式表单。我进去一看 http://jquerymobile.com/test/docs/api/events。 HTML 但由于文档是pretty的无助于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('创建'); 上形式初始化任何小部件(表单元素)你刚才又说:

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/