How can I detect that the (X) close button of a jQuery UI Dialog was clicked, separately from the dialogclose/dialogbeforeclose events?

前端 未结 4 1117
遇见更好的自我
遇见更好的自我 2021-02-19 07:43

I\'d like to be able to detect the (x) close button of a jQuery UI Dialogue being clicked, but I don\'t want to use the dialogclose / dialogbeforeclose

4条回答
  •  别跟我提以往
    2021-02-19 08:05

    you could do exactly what JAAulde suggested, or avoiding tracking binding and use the create event:

    $(document).ready(function() {
        $('#dialog').dialog({
            create: function() {
                $(this).closest('div.ui-dialog')
                       .find('.ui-dialog-titlebar-close')
                       .click(function(e) {
                           alert('hi');
                           e.preventDefault();
                       });
            }
        });
    });
    

提交回复
热议问题