如何在淘汰赛foreach循环中呈现jQuery移动复选框?(How to render a jQuery mobile checkbox within a knockout foreach loop

编程入门 行业动态 更新时间:2024-10-27 02:17:47
如何在淘汰赛foreach循环中呈现jQuery移动复选框?(How to render a jQuery mobile checkbox within a knockout foreach loop?)

当我在淘汰赛的foreach循环中时,我似乎在渲染标准jQuery复选框时遇到了困难。

使用这样的标准代码看起来很好:

<input type="checkbox" data-theme="c" name="checkbox-1" id="checkbox-1" class="custom" data-bind="checked: error, click: acceptChanges" /> <label for="checkbox-1">Error</label> <input type="checkbox" data-theme="c" name="checkbox-2" id="checkbox-2" class="custom" data-bind="checked: information, click: acceptChanges" /> <label for="checkbox-2">Information</label>

但是当我在foreach循环中尝试这个时,它会变得非常小!

<!-- ko foreach: selectedLogTypes --> <input type="checkbox" data-theme="c" class="custom" data-bind="jqmChecked: isSelected, attr: { 'id': 'checkbox_' + $index(), 'name': 'checkbox_' + $index() }" /> <label data-bind="text: logType, attr: { 'for': 'checkbox_' + $index() }"></label> <!-- /ko -->

这是一个展示问题的小提琴样本的链接。

http://jsfiddle.net/mheere/A33Ng/1/

任何帮助非常感谢!

I seem to be having difficulties rendering a standard jQuery checkbox when I am inside a knockout foreach loop.

It looks fine using standard code like this:

<input type="checkbox" data-theme="c" name="checkbox-1" id="checkbox-1" class="custom" data-bind="checked: error, click: acceptChanges" /> <label for="checkbox-1">Error</label> <input type="checkbox" data-theme="c" name="checkbox-2" id="checkbox-2" class="custom" data-bind="checked: information, click: acceptChanges" /> <label for="checkbox-2">Information</label>

But when I try this within a foreach loop it renders very small!

<!-- ko foreach: selectedLogTypes --> <input type="checkbox" data-theme="c" class="custom" data-bind="jqmChecked: isSelected, attr: { 'id': 'checkbox_' + $index(), 'name': 'checkbox_' + $index() }" /> <label data-bind="text: logType, attr: { 'for': 'checkbox_' + $index() }"></label> <!-- /ko -->

Here is the link to a fiddle sample demonstrating the problem.

http://jsfiddle.net/mheere/A33Ng/1/

Any help much appreciated!

最满意答案

您需要手动增强checkbox和controlgroup 。

$("[type=checkbox]").checkboxradio(); $("[data-role=controlgroup]").controlgroup();

演示

You need to enhance checkbox and controlgroup manually.

$("[type=checkbox]").checkboxradio(); $("[data-role=controlgroup]").controlgroup();

Demo

更多推荐

本文发布于:2023-08-07 21:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465642.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:淘汰赛   复选框   如何在   foreach   knockout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!