【问题标题】:Binding knockout array to render jqm radio buttons绑定敲除数组以呈现 jqm 单选按钮
【发布时间】:2014-09-24 05:22:01
【问题描述】:

我正在尝试呈现单选按钮列表。我从这个 url 修改了代码示例,最后得到了这段废话/代码,

http://demos.jquerymobile.com/1.0a4.1/docs/forms/forms-radiobuttons.html

<fieldset data-role="controlgroup">
    <legend>Choose a pet:</legend>
        <!-- ko foreach: pets -->
            <input type="radio" name="radio1" data-bind="value: id, checked: $root.selectedID, attr: {'id': 'radio-1' + $index() }" />
            <label data-bind="attr: {'for': 'radio1' + $index() }, text: name"></label>
        <!-- /ko -->
</fieldset>

我不知道我做错了什么。我在渲染的 html 中看到,div(带有 ui-radio 类)只围绕输入,标签在 div 之外。并且生成的单选按钮列表完全没有格式。

我做错了什么?

谢谢。

【问题讨论】:

  • jquery-mobile 在初始化过程中会大量修改 DOM,很难让它与淘汰赛一起工作。
  • 如果您在 jquery doc 页面上检查无线电输入的 DOM,您会发现它与示例 HTML 代码完全不同。

标签: jquery jquery-mobile knockout.js


【解决方案1】:

您需要告诉 jquery mobile 手动增强这些功能。这样做的方法如下:

$('[type="radio"]').checkboxradio();

https://stackoverflow.com/a/14550417/725866

【讨论】:

    猜你喜欢
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 2014-10-16
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多