如何在jquery对话框中将对话框按钮名称作为变量传递

时间:2022-01-06 20:42:47

Here I want dialogue box button values 'yes','no' as a variable.I want to pass the variable butt1 to buttons .

在这里,我希望对话框按钮值为“是”,“否”作为变量。我想将变量butt1传递给按钮。

 var button ='Yes'
 $("#modal_confirm_yes_no").dialog({
        bgiframe: true,
        autoOpen: false,
        minHeight: 200,
        width: 350,
        modal: true,
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        buttons: {
                'Yes': function(){
                    $(this).dialog('close');
                    callback(true);
                },
                'No': function(){
                    $(this).dialog('close');
                    callback(false);
                }
            }
    });

1 个解决方案

#1


3  

 var button ='Yes'
 $("#modal_confirm_yes_no").dialog({
    bgiframe: true,
    autoOpen: false,
    minHeight: 200,
    width: 350,
    modal: true,
    closeOnEscape: false,
    draggable: false,
    resizable: false,
    buttons: [
        {text: button, click: function() {
            $(this).dialog('close');
            callback(true);
        }},
        {text: 'No', click: function() {
            $(this).dialog('close');
            callback(false);
        }}
    ]
});

#1


3  

 var button ='Yes'
 $("#modal_confirm_yes_no").dialog({
    bgiframe: true,
    autoOpen: false,
    minHeight: 200,
    width: 350,
    modal: true,
    closeOnEscape: false,
    draggable: false,
    resizable: false,
    buttons: [
        {text: button, click: function() {
            $(this).dialog('close');
            callback(true);
        }},
        {text: 'No', click: function() {
            $(this).dialog('close');
            callback(false);
        }}
    ]
});