Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导盒确认回调立即执行,无需单击按钮_Javascript_Jquery - Fatal编程技术网

Javascript 引导盒确认回调立即执行,无需单击按钮

Javascript 引导盒确认回调立即执行,无需单击按钮,javascript,jquery,Javascript,Jquery,我正在显示一个引导框确认对话框。我想要的是,当我点击“Ok”按钮时,它将触发我的回调函数。但是,在显示对话框时,回调函数立即执行。这是我的代码: var update_violator = function update_violator(){ var update_message = ""; var callback_func = new function(){ console.log('Executed agad!');

我正在显示一个引导框确认对话框。我想要的是,当我点击“Ok”按钮时,它将触发我的回调函数。但是,在显示对话框时,回调函数立即执行。这是我的代码:

var update_violator = function update_violator(){
        var update_message = "";

        var callback_func = new function(){

                console.log('Executed agad!');
                //selected violator is assigned by referrence. Any changes made to this object automatically reflected in violators array.
                selected_violator.alias = $('#alias_v').val();
                selected_violator.first_name = $('#first_name_v').val();
                selected_violator.last_name = $('#last_name_v').val();
                selected_violator.middle_name = $('#middle_name_v').val();
                selected_violator.birth_date = $("input[name='birthdate_v']").val();
                selected_violator.gender = $("input[name='gender_v']:checked").val();
                selected_violator.educational_attainment = $('#educational_attainment_v').val();
                selected_violator.weight = $('#weight_v').val();
                selected_violator.height = $('#height_v').val();
                selected_violator.eyes_color = $('#eyes_color_v').val();
                selected_violator.hair_color = $('#hair_color_v').val();
                selected_violator.identifying_marks = $('#ident_marks_v').val();
                selected_violator.nationality = $('#nationality_v').val();
                selected_violator.mother_name = $('#mother_name_v').val();
                selected_violator.father_name = $('#father_name_v').val();
                selected_violator.father_name = $('#father_name_v').val();
                selected_violator.contact_person = $('#contact_person_v').val();
                selected_violator.contact_info = $('#contact_info_v').val();
                selected_violator.relationship = $('#relationship_v').val();
                selected_violator.street_name = $('#street_name_v').val();
                selected_violator.barangay_name = $('#barangay_name_v').val();
                selected_violator.city_name = $('#city_name_v').val();

                if(selected_violator.is_existing == true){
                    update_message="Violator successfully updated!\n This violator has a previous record in the database, in order to reflect the changes\n" +
                    " you've made you need to save the case report accordingly."
                }else{
                    update_message = "Violator successfully updated!"
                }

                bootbox.alert({ 
                    message: update_message,
                    title: "Message",
                    callback: function(){
                        $('#viewViolatorModal').modal('hide');
                        //console.log("Here: " + violators[0].alias);   
                    }           
                }); 

                update_violator_photos();               
        }
        Main.Mod.show_bootbox_confirm('Are you sure you want to update this violator?', 'Message', callback_func);  
    }
我的show\u bootbox\u confirm():

非常感谢您的回复

谢谢

var show_bootbox_confirm = function show_bootbox_confirm(message, title, callback_func){
        bootbox.dialog({
            message: message,
            title: title,
            buttons: {
                success: {
                      label: "Ok",
                      className: "btn-success",
                      callback: callback_func,
                    },
                danger: {
                      label: "Cancel",
                      className: "btn-danger",
                      callback: function() {

                    }
                },
            }
        })  
    };