我有一個包含8個不同單選按鈕組的頁面('yes/no'按鈕組)。最初我已經編碼的HTML來呈現與'否'按鈕選中,但現在我需要渲染時沒有選擇按鈕。單選按鈕呈現爲'checked = checked',不確定源
我刪除了'checked = checked'並刷新了,但仍然選擇了NO按鈕。我再次刷新,清除緩存,並運行在不同的瀏覽器無濟於事。我正在尋找幫助尋找可能的原因。
我的MVC代碼:
@Html.RadioButtonFor(m => m.IsFelon, true, new { @class = "commentBox RadioIf" })
<label for="PersonModel_Felon">Yes</label>
@Html.RadioButtonFor(m => m.IsFelon, false, new { @class = "commentBox" })
<label for="PersonModel_Felon">No</label>
它是如何呈現:
<input class="commentBox" data-val="true" data-val-required="The ChildAbusePast field is required." id="ChildAbusePast" name="ChildAbusePast" type="radio" value="True" />
<label for="HistoryModel_ChildAbusePast">Yes</Label>
<input checked="checked" class="commentBox" id="ChildAbusePast" name="ChildAbusePast" type="radio" value="False" />
<label for="HistoryModel_ChildAbusePast">No</Label>
唯一的其他東西接觸,這是一些jQuery的:
$(document).ready(function() {
$("input.commentBox").click(function() {
if ($(this).closest('div.editor-field2').children('input:checked').val() == "True") {
$(this).closest('div.formQuestion').children('div.hidden').slideDown(800);
} else {
$(this).closest('div.formQuestion').children('div.hidden').slideUp("fast");
}
});
});
您是否使用'Model'數據預填充表單?如果是,請檢查這些值是否設置爲「false」。 – Jack