【问题标题】:How to render a jQuery mobile checkbox within a knockout foreach loop?如何在淘汰赛 foreach 循环中呈现 jQuery 移动复选框?
【发布时间】:2013-11-14 04:37:18
【问题描述】:

当我处于淘汰赛 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/

非常感谢任何帮助!

【问题讨论】:

    标签: jquery-mobile knockout.js


    【解决方案1】:

    您需要手动增强checkboxcontrolgroup

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

    Demo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2013-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-10
      • 1970-01-01
      相关资源
      最近更新 更多