我正在使用jquery模板显示一些数据列表,我有一些单选按钮控件,因此在初始化模板单选按钮后如果获取值为true则不会被检查。 以下是我的
代码 InitializeUniversityAllocationControl: function (referenceList) {
if (referenceList != undefined && referenceList != "") {
var obj = JSON.parse(referenceList.replace(/"/ig, '"'));
if (obj.length > 0) {
for (i = 0; i < obj.length; i++) {
var ref = new AllocationModel(i);
//ref.Id = obj[i].Id;
ref.UnvId = obj[i].UnvId;
ref.IsAllowed = obj[i].IsAllowed;
ref.IsDefault = obj[i].IsDefault;
ref.ListingOnUniversity = obj[i].ListingOnUniversity;
this.AllocationIndex = i;
$("#referenceTemplate").tmpl(ref).appendTo("#divUnvAllocationContainer");
$('#templateContainer' + i).find(".name").val(ref.UnvId);
}
this.AllocationIndex = this.AllocationIndex + 1;
}
}
}
我的Html模板如下所示:
<div class="radio-list">
<label class="radio-inline">
<input type="radio" value=${IsAllowed} name="AllocatedUniversityList[${Index}].IsAllowed" class="rbIsAllowed" id="AllocatedUniversityList[${index}].isallowed"/>Yes
@*@Html.RadioButton("AllocatedUniversityList[${Index}].IsAllowed", true, new { @id = "AllocatedUniversityList[${Index}].IsAllowed", @class = "rbIsAllowed"}) Yes*@
</label>
<label class="radio-inline">
<input type="radio" value=${IsAllowed} name="AllocatedUniversityList[${Index}].IsAllowed" class="rbIsAllowed" id="AllocatedUniversityList[${index}].isallowed" />No
@*@Html.RadioButton("AllocatedUniversityList[${Index}].IsAllowed", false, new { @id = "AllocatedUniversityList[${Index}].IsAllowed", @class = "rbIsAllowed", }) No*@
</label>
</div>