jquery-mobile创建动态控件组并应用jquery-ui css [英] jquery-mobile create dynamic controlgroup and apply jquery-ui css

查看:141
本文介绍了jquery-mobile创建动态控件组并应用jquery-ui css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码: http://jsfiddle.net/YKvR3/34/

我将使用数组(名称)中的值创建一个控制组. 问题是,当我单击加载"按钮时,值已添加到控件组中,但未加载jquery-ui样式,如图像中所示. 控件组未使用jquery-ui移动CSS设置样式.

I would create a controlgroup with values that are in my array (name). The problem is that when I click load button the values are added in a controlgroup but the jquery-ui styles are not loaded like in the image. The controlgroup is not styled with 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();});​

我做错了什么? 谢谢.

What I am doing wrong? Thanks.

推荐答案

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

来自: jqm文档

如果您在客户端生成新的标记或通过Ajax加载内容并将其注入到页面中,则可以触发create事件来处理新标记中包含的所有插件的自动初始化.可以在任何元素(甚至是页面div本身)上触发此操作,从而省去了手动初始化每个插件(列表视图按钮,选择等)的任务.

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

这篇关于jquery-mobile创建动态控件组并应用jquery-ui css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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