这个特性没有内置到 jQM 中,但是你可以通过一些 CSS 和脚本来实现它。
给定标准垂直标记:
<fieldset data-role="controlgroup" data-mini="true" class="vertBackground">
<legend>Vertical, mini sized:</legend>
<input type="radio" name="radio-choice-v-6" id="radio-choice-v-6a" value="on" checked="checked" />
<label for="radio-choice-v-6a">One</label>
<input type="radio" name="radio-choice-v-6" id="radio-choice-v-6b" value="off" />
<label for="radio-choice-v-6b">Two</label>
<input type="radio" name="radio-choice-v-6" id="radio-choice-v-6c" value="other" />
<label for="radio-choice-v-6c">Three</label>
</fieldset>
我给了控制组一个类vertBackground
来制作特定于这个组的 jQuery 和 CSS 选择器。我应用了一些 CSS 来隐藏复选标记并将文本移回按钮的左侧:
.vertBackground .ui-icon{
display: none;
}
.vertBackground .ui-btn-inner{
padding-left: 11px !important;
}
最后,我添加了检查单选按钮何时更改的脚本,并将类 ui-btn-active 添加到当前检查的标签中:
$(document).on("pageinit", "#page1", function(){
SetActive();
$(".vertBackground input[type='radio']").on("change", function(){
setTimeout(SetActive, 0);
});
});
function SetActive(){
$(".vertBackground .ui-radio-off").removeClass("ui-btn-active");
$(".vertBackground .ui-radio-on").addClass("ui-btn-active");
}
这是一个 演示