Nuvolari
Nuvolari

Reputation: 1155

Jquery UI Dialog - Custom Close Button (X)

I would like to set some custom functions for when I click the standard X button. I have scrolled through the API and all related information and it is completely barren when it comes to this. The documentation is shockingly poor and rather sub standard for such a commonly used piece of software.

What I want to do is when the X is clicked I would like it to run some custom code. Unfortunetely the X button lacks an id and there is no documentation on how to access it directly. I have seen answers on here suggesting users to create a "Close" button but that seems rather pointless as it already comes with one and further more I don't wish to have a close button located at the bottom of the window but in the title bar.

Upvotes: 1

Views: 1656

Answers (2)

user1726343
user1726343

Reputation:

You can use:

$( "#dialog" ).dialog({
beforeClose:function(e){
//do something here
}
});

Upvotes: 2

david9
david9

Reputation: 169

try this

  $(".ui-dialog-titlebar-close").click( function() {
     //some code
 });

Upvotes: 3

Related Questions