jQuery UI dialog - problem with event on close

前端 未结 3 465
刺人心
刺人心 2021-01-15 23:25

I\'m trying to perform a specific action when I close a jQuery UI dialog. Here\'s a simplified version of my code:

$(\'a.open-trigger\').click(function(){
           


        
3条回答
  •  暖寄归人
    2021-01-15 23:56

    You need to take the close click event handler out of the open click event handler

    $(function() {
        $('#dialog').dialog({bgiframe: true, dialogClass: 'change', resizable: false, draggable: false, modal: true, height: 334, width: 450, autoOpen: false, show: 'fade'});
    
        $('a.open-trigger').click(function(){    
            $('#dialog').dialog('open');
        });
    
    
        $('a.close-trigger').click(function(){
            alert("hello");
            var myDialog = $('#dialog');
            if (myDialog.dialog('isOpen'))
                myDialog.dialog('close');
        });
    });
    

提交回复
热议问题