Soft
Soft

Reputation: 1804

Overriding jQuery Dialog method

I am trying to override close method of Jquery Dialog method.

Code :

jQuery.Dialog.close = function() {
    alert('my close');
}

But its not working. Please help.

Upvotes: 1

Views: 4941

Answers (2)

Nate Kindrew
Nate Kindrew

Reputation: 861

There is an event called beforeClose which would allow you to do what you want, I think. When it fires, you can hide the dialog, then return false, which would prevent the dialog from actually closing.

$( ".selector" ).dialog({
   beforeClose: function(event, ui) { 
       $(this).hide();
       return false;
   }
});

Reference: http://jqueryui.com/demos/dialog/ under the Events tab below the example

Upvotes: 5

Jason
Jason

Reputation: 52523

You're setting it up wrong. Check this out to see how to do it correctly.

Ok, so that link doesn't take you where I thought it would. Here's the relevant bit from jqueryui.com.

closeType:dialogclose
This event is triggered when the dialog is closed.

Code examples

Supply a callback function to handle the close event as an init option.
$('.selector').dialog({
   close: function(event, ui) { ... }
});
Bind to the close event by type: dialogclose.
$('.selector').bind('dialogclose', function(event, ui) {
  ...
});

Upvotes: 3

Related Questions