使用javascript生成分组复选框JQuery mobile(Generate grouped checkboxes JQuery mobile with javascript)
请检查此代码: http : //jsfiddle.net/Hce8y/
我正在尝试生成一个分组复选框列表:
function ItemCode_Changed(sender, onload) { $('#category-contianer-id-3').append( '<div data-role="fieldcontain">' + '<fieldset data-role="controlgroup">' + '<legend>Choose as many:</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>'); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain(); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain('refresh'); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio(); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio('refresh'); //$('#my-home').page();}
当更改输入中的文本时,但结果看起来不像演示。
有任何错误,任何帮助表示赞赏。
Please check this code: http://jsfiddle.net/Hce8y/
I'm trying to generate a list of grouped check boxes:
function ItemCode_Changed(sender, onload) { $('#category-contianer-id-3').append( '<div data-role="fieldcontain">' + '<fieldset data-role="controlgroup">' + '<legend>Choose as many:</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>'); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain(); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain('refresh'); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio(); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio('refresh'); //$('#my-home').page();}
when change the text in the input, but the result doesn't looks like the demo.
Is there any mistakes, any help are appreciated.
最满意答案
你必须调用这两种方法:
$('input[type=checkbox]').checkboxradio(); $('fieldset').controlgroup();更改其子元素后调用fieldcontain()不会改变任何内容。 至少我没有看到任何差异。
You have to call both methods:
$('input[type=checkbox]').checkboxradio(); $('fieldset').controlgroup();Calling fieldcontain() after changing its child-elements doesn't change anything. At least I was not able to see any differences.
更多推荐
>',type,check,电脑培训,计算机培训,IT培训"/> <meta name="descrip
发布评论