动态控制组和复选框未设置样式 [英] Dynamic controlgroup and checkboxes unstyled

查看:115
本文介绍了动态控制组和复选框未设置样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图将动态内容直接加载到我的复选框容器(group_checkboxes)

So I'm trying to load dynamic content straight into my checkbox container (group_checkboxes)

<div id='group_checkboxes' data-role="fieldcontain">

</div>

这是我运行以填充容器的语句:

This is the statement I'm running to populate the container:

$('#group_checkboxes').append('<fieldset data-role="controlgroup"><input type="checkbox" name="' + $(this).find('data').text() + '" class="custom" /><label for="' + $(this).find('data').text() + '">' + $(this).find('label').text() + '</label></fieldset>');

复选框都已填充,但未应用jQuery样式。

The checkboxes are all populated but the jQuery style is not applied.

根据文档我需要的全部内容要做的是调用此函数更新复选框样式...

According to the docs all I need to do is call this function to update the checkbox style...

$("input[type='checkbox']").checkboxradio("refresh");

这不工作虽然...任何想法我做错了什么? >

That doesn't work though... Any idea what I'm doing wrong?

推荐答案

首先尝试自己的静态演示代码:

First try their own static demo code:

<div  data-role="fieldcontain">
                <fieldset data-role="controlgroup">
                    <legend>Choose as many snacks as you'd like:</legend>
                    <input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" />
                    <label for="checkbox-1a">Cheetos</label>

                    <input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" />
                    <label for="checkbox-2a">Doritos</label>

                    <input type="checkbox" name="checkbox-3a" id="checkbox-3a" class="custom" />
                    <label for="checkbox-3a">Fritos</label>

                    <input type="checkbox" name="checkbox-4a" id="checkbox-4a" class="custom" />
                    <label for="checkbox-4a">Sun Chips</label>
                </fieldset>
            </div>

他们只使用一个字段集,如我在评论中提到的。

然后调整脚本以动态生成相同的标记,然后刷新它们。

They are using just one fieldset as I mentioned in comments.
If this works, then adjust your script to generate the same markup dynamically and then refresh them

$("input[type='checkbox']").checkboxradio("refresh");

如果这将与他们的代码一起使用,你会知道你在标记中有错误。如果没有,则刷新函数出错。 (我知道这不是最终的解决方案,但你必须做一些调试有时:)

If this will work with their code, you will know that you have error in markup. If not, there is an error with that refresh function. (I know it's not final solution but you have to do a bit of debugging sometimes :)

编辑:

发现类似的问题, Page()

JQM常见问题 < br>
问题

这篇关于动态控制组和复选框未设置样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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