以下代码为什么返回错误:
<script type="text/javascript">
$(document).ready(function () {
$("#chkIssueCredit").change(function () {
if (!$(this).prop('checked')) {
bootbox.confirm("Are you sure you do not want to issue a credit? Please confirm."), function (result) {
if (result) {
$(this).prop('checked', true);
}
}
return false;
//if (!confirm("Are you sure you do not want to issue a credit? Please confirm.")) {
// $(this).prop('checked', true);
//};
};
});
});
</script>
答案 0 :(得分:1)
您将在第一个参数(消息)后立即关闭Confirm方法。在这里尝试这个:
<script type="text/javascript">
$(document).ready(function () {
$("#chkIssueCredit").change(function () {
if (!$(this).prop('checked')) {
bootbox.confirm("Are you sure you do not want to issue a credit? Please confirm.", function (result) {
if (result) {
$(this).prop('checked', true);
}
});
return false;
//if (!confirm("Are you sure you do not want to issue a credit? Please confirm.")) {
// $(this).prop('checked', true);
//};
};
});
});
</script>
您能看到区别吗?