我在 MVC 项目中使用 sweetalert,并使用 CheckBoxFor html helper 将复选框呈现给 sweetalert。但是当我点击这些复选框时,有时它会被点击,有时它不会被点击。我没有得到这种奇怪行为背后的原因。
在同一个地方我尝试添加普通的 html 复选框,这些复选框工作得很好。
任何人都可以帮助了解这种奇怪行为背后的原因吗?
代码:
看法:
<table class="table">
@foreach (var item in Model)
{
<tr>
<td>
<input type="checkbox" name="Asha" style = "display:block;height:20px;width:20px;"/>
</td>
<td style="padding-left:20%">
@Html.CheckBoxFor(modelItem => item.Status,htmlAttributes: new { style = "display:block;height:20px;width:20px;", id = item.Id ,Class = "process-to-lock", value = item.Name})
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
</tr>
}
</table>
甜蜜警报:
$("#unLockNominations").click(function (e) {
showCustomLoader();
$.ajax({
type: 'GET',
url: '@Url.Action("UnlockNomination", "Review")',
dataType: 'html',
success: function (result) {
hideCustomLoader();
swal({
title: "Awards to unlock",
html: true,
text: result,
showConfirmButton: ($(result).filter('#no-awards').text() == undefined || $(result).filter('#no-awards').text() == ""),
confirmButtonColor: "#0070b9",
confirmButtonText: "Submit",
showCancelButton: true,
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: true
}
}
在上面的代码中,以甜蜜警报呈现的文本是我上面提到的一个 html 表格。