JqueryMobile radiobutton水平组无法正确渲染

时间:2013-08-26 10:48:21

标签: jquery html jquery-mobile radio-button

我正在尝试以编程方式在JqueryMobile中创建一组单选按钮。除data-type='horizontal'属性外,一切正常:

正如您在 this 小提琴中看到的那样,“created-via-js”广播组无法正常呈现,而另一个(直接写入HTML)效果很好

我正在关注您可以在 this 页面找到的横向群组示例

这是代码:

HTML

<div id="container"></div>

JS

for (var x = 0; x < 2; x++) {
    var rowList1 = '<fieldset data-role="controlgroup" data-type="horizontal">' +
        '<legend>This does not render properly..</legend>' +
        '<input name="radio-choice-h-2" id="radio-choice-h-2a" value="on" checked="checked" type="radio">' +
        '<label for="radio-choice-h-2a">One</label>' +
        '<input name="radio-choice-h-2" id="radio-choice-h-2b" value="off" type="radio">' +
        '<label for="radio-choice-h-2b">Two</label>' +
        '<input name="radio-choice-h-2" id="radio-choice-h-2c" value="other" type="radio">' +
        '<label for="radio-choice-h-2c">Three</label>' +
        '</fieldset>';
    $("#container").append(rowList1);
}
$("input[type='radio']").checkboxradio().checkboxradio("refresh");

我做错了什么?有什么想法吗?

提前致谢,最好的问候

1 个答案:

答案 0 :(得分:1)

尝试在父容器上触发create方法,而不是直接在输入上触发,例如

$('#container').trigger('create');

jsfiddle

相关问题