使用modal true打开jquery对话框后启用按钮

时间:2021-12-19 20:38:28

I want to enable a button after that i have opened a jquery dialog with option modal set to true.The button obviously is outside the dialog. I already know that this seems to be a strange request but i need this behaviour because I have a form in the dialog so after click on the button to submit the data I have to append the dialog at the end of the form and then click agin on the button that now is outside of the dialog.

我想启用一个按钮,之后我打开了一个jquery对话框,选项模式设置为true。按钮显然在对话框之外。我已经知道这似乎是一个奇怪的请求,但我需要这种行为,因为我在对话框中有一个表单,所以在单击按钮提交数据后,我必须在表单的末尾附加对话框,然后单击agin在现在位于对话框之外的按钮上。

Thank you in advance.

先谢谢你。

2 个解决方案

#1


2  

Use te open event that is fired whenever the dialog is opened

使用在打开对话框时触发的te open事件

$( ".selector" ).dialog({
   open: function(event, ui) { 
        $('#yourhiddenbutton').show();
    }
});

EDIT - you could do it like this

编辑 - 你可以这样做

$(function() {            
    $("#dialogRifiuto").dialog({
        width: 'auto',
        autoOpen: true,
        closeOnEscape: true,
        modal: true,
        resizable: false,
        open: function(){
            //change the z-index and position the div where you want
            $('#a').css({'z-index':  1005, 'position': 'absolute', 'top': 0 });            
        },
        close: function(){
            //go back to normal
            $('#a').css({'z-index':  1, 'position': 'static' });        
        }

    })

});

#2


0  

You can enable the button using $('#myButton').removeAttr('disabled');

你可以使用$('#myButton')启用按钮.removeAttr('disabled');

#1


2  

Use te open event that is fired whenever the dialog is opened

使用在打开对话框时触发的te open事件

$( ".selector" ).dialog({
   open: function(event, ui) { 
        $('#yourhiddenbutton').show();
    }
});

EDIT - you could do it like this

编辑 - 你可以这样做

$(function() {            
    $("#dialogRifiuto").dialog({
        width: 'auto',
        autoOpen: true,
        closeOnEscape: true,
        modal: true,
        resizable: false,
        open: function(){
            //change the z-index and position the div where you want
            $('#a').css({'z-index':  1005, 'position': 'absolute', 'top': 0 });            
        },
        close: function(){
            //go back to normal
            $('#a').css({'z-index':  1, 'position': 'static' });        
        }

    })

});

#2


0  

You can enable the button using $('#myButton').removeAttr('disabled');

你可以使用$('#myButton')启用按钮.removeAttr('disabled');