Bootbox - 确认模态DIalog Box需要回拨功能......但我有一个

问题描述 投票:-2回答:1

为什么以下代码返回错误:

<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>
jquery bootstrap-4 bootbox
1个回答
1
投票

您正在关闭第一个参数(消息)后面的确认方法。试试这个:

<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>

你能看到区别么?

© www.soinside.com 2019 - 2024. All rights reserved.