开发者

Overriding jQuery Dialog method

开发者 https://www.devze.com 2022-12-15 02:57 出处:网络
I am trying to override close method of Jquery Dialog method. Code : jQuery.Dialog.close = function() {

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

Code :

jQuery.Dialog.close = function() {
    al开发者_JAVA技巧ert('my close');
}

But its not working. Please help.


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


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) {
  ...
});
0

精彩评论

暂无评论...
验证码 换一张
取 消