引导框确认-当选择OK时包含href

bootbox confirm - include href when OK is selected

本文关键字:OK 包含 href 选择 确认      更新时间:2023-09-26

我试图在bootbox.js添加到测试页面。

目前,当我在触发引导框的超链接中包含href标签时,无论我点击什么确认按钮(取消或确定),都会触发href。

我如何将href标签包含到bootbox js代码中,只有当用户选择OK确认选项时才会触发?我试了几次,但都没有用。

下面是带有href标签的超链接:

<a id="id_customized_details_duplicate" href="{% url customized_details_duplicate customized_detail.id %}">Duplicate</a>

这是我的bookbox js代码:

    $(document).ready(function(){
        $('#id_customized_details_duplicate').on('click', function(){
            bootbox.confirm("Are you sure?", function(result) {
                if (result) {
                    //include the href duplication link here?;
                    //showProgressAnimation();
                    alert('OK SELECTED');
                } else {
                    alert('CANCEL SELECTED');
                }
            });
        });
    });

尝试这样做,防止anchor tag &在bootbox确认处理程序中添加具有相应href位置的窗口重定向调用(当单击"OK"选项时)。

 $(document).ready(function(){
    $('#id_customized_details_duplicate').on('click', function(event){
                   event.preventDefault();
        bootbox.confirm("Are you sure?", function(result) {
            if (result) {
                 //include the href duplication link here?;
                 window.location = $(this).attr("href");
                //showProgressAnimation();
                alert('OK SELECTED');
            } else {
                alert('CANCEL SELECTED');
            }
        });
    });
});

现场演示:http://jsfiddle.net/dreamweiver/9he30z4y/255/

Happy Coding:)