最初动态创建单选组时,我的控制组(jquery mobile 1.4)呈现完美,但是当我向其中添加另一个单选时,按钮的样式却是分开的。当我重新加载应用程序时,它们又在一起了。
function showPlaces() {
$('#radio-group').empty();
for(var i = 0; i < connections.length; i++) {
$('#radio-group').append('<label><input type="radio" name="places" id="' + i + '" />' + place + '</label>');
}
$('input[type=radio]').checkboxradio().trigger('create');
$('#radio-group').controlgroup().trigger('create');
}
//在应用启动时调用该函数,在我添加另一个位置后再次调用
我尝试过的其他一些事情:
$("#radio-group").controlgroup("refresh");
$('#radio-group').controlgroup('refresh');
$("[data-role=controlgroup]").controlgroup("refresh");
$('input[type=radio]').checkboxradio('refresh');
在.append之前也尝试过.controlgroup('container'),但得到“初始化前无法在controlgroup上调用方法”。
这是html:
<form>
<fieldset data-role="controlgroup" id="radio-group">
<!-- Dynamically injected radio buttons go here -->
</fieldset>
</form>
你应该.append()
物品进入.controlgroup("container")
内部进行循环,然后提升单选按钮.checkboxradio()
。
for(var i = 0; i < connections.length; i++) {
$('#radio-group')
.controlgroup("container")
.append('<label><input type="radio" name="places" id="+i+" />Place</label>');
}
$("#radio-group")
.enhanceWithin()
.controlgroup("refresh");
您甚至不需要使用.checkboxradio()
,而是.enhanceWithin()
在父容器上使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句