user3230561
user3230561

Reputation: 445

Jquery dialog box close issue

I am using jquery ui dialog box. My question, I want to track the okay button and close dialog which is the X button on the dialog box separately. If the dialog is closed using X button then the dialog close event should not occur.

Upvotes: 0

Views: 84

Answers (4)

neel shah
neel shah

Reputation: 2271

You should use the the dialogclose event

$( ".dropDownBox" ).on( "dialogclose", function( event, ui ) {} );

you can then use the event variable inside the function for finding either it was x or ok button

Upvotes: 0

dima
dima

Reputation: 1189

You can just track buttons like this. That way you won't track the X button but just those that you want to.

$( ".selector" ).dialog({ 
   buttons: [ { text: "Ok", click: function() { 
      //TRACK IT HERE
      $( this ).dialog( "close" ); 
   } } ] 
});

Upvotes: 0

Joakim M
Joakim M

Reputation: 1803

If using jQuery you can try using the beforeClose option!

$( "#yourdialog" ).dialog({
   beforeClose: function(event, ui) { ... }
});

Upvotes: 0

Neel
Neel

Reputation: 11741

Using CSS that does not over ride every dialog on the page.

The CSS

.no-close .ui-dialog-titlebar-close {display: none }

The HTML

<div class="selector" title="No close button">
    Dialog box without close button
</div>

demo here

http://jsfiddle.net/AGZKF/413/

Upvotes: 1

Related Questions