[英]RadioButton jQuery Mobile formatting issues
I am trying to get a radio button list using an AJAX call. 我正在尝试使用AJAX调用获取单选按钮列表。 However there are problems in the formatting with my list looking like this.
但是,我的列表看起来像这样在格式化方面存在问题。
(Radio-button)
Text
This is my code: 这是我的代码:
$.get(
"schedulePortal.php?uid="+uid,
function( data ){
$('#semList').html( data )
.controlgroup( 'refresh' );
});
HTML: HTML:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" id="semList" style="margin-left : 30px;">
<!-- FROM PHP Response -->
<input type="radio" class="radio-choice" value="'.$row['Enrolment_session'].'_'.$row['Semester_session'].'" />';
<label>'.$row['Enrolment_session'].' '.$row['Semester_session'].'</label>;
<!-- END OF PHP Response -->
</fieldset>
</div>
There are 2 problems with your code: 您的代码有2个问题:
The label needs a for attribute and the input needs a unique id such that the for and id have the same value. 标签需要一个for属性,输入需要一个唯一的id,以便for和id具有相同的值。 e,g:
例如:
<input type="radio" name="radioGroup" id="rad0" class="radio-choice">
<label for="rad0">The Radio Label</label>
After adding the dynamic radio buttons, instead of refreshing the controlgroup, initialize the checkboxradio widget: 添加动态单选按钮后,而不是刷新控制组,而是初始化checkboxradio小部件:
$('#semList').html( data );
$('#semList input[type="radio"]').checkboxradio();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.