Search code examples
javascriptjqueryhtmljquery-uijquery-dialog

Enable a button after open jquery dialog with modal true


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.

Thank you in advance.


Solution

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

    $( ".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' });        
            }
    
        })
    
    });