jquery-mobile创建动态控制组并应用jquery-ui css

前端之家收集整理的这篇文章主要介绍了jquery-mobile创建动态控制组并应用jquery-ui css前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Dynamic controlgroup and checkboxes unstyled6个
这是我的代码
http://jsfiddle.net/YKvR3/34/

我将创建一个控件组,其值在我的数组(名称)中.
问题是,当我单击加载按钮时,值将添加到控件组中,但jquery-ui样式不会像图像中那样加载.
控制组未使用jquery-ui mobile css进行样式设置.

$("#load").click(function(){
var name=["one","two"];
var html='<fieldset id="listPlayers" data-role="controlgroup"><legend><h1>Choose as many players as youd like to remove:</h1></legend>';
for ( var int = 0; int < 2; int++) {
        html+='<input type="checkBox" name="checkBox-'+int+'a" id="checkBox-'+int+'a" class="custom" /><label for="checkBox-'+int+'a">'+name[int]+'</label>';
    }
    alert('<legend><h3>Choose as many players as you would like to remove:</h3></legend>'+html+'</fieldset');
    $("#list").html(html+'</fieldset');       
//$("#list").page();});​

我做错了什么?
谢谢.

解决方法

$("#list").trigger('create');

来自:jqm docs

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.).

原文链接:https://www.f2er.com/jquery/177482.html

猜你在找的jQuery相关文章