开发者

JQuery-ui Dialog: How can I prevent default action when the user clicks on close button?

i'm using JQuery-ui dialog;

i'd like to perform my custom actions when user clicks on dialog's close button [X], but i'd like to prevent the closing event too!

i tried this code without success:

$( ".selector开发者_StackOverflow社区" ).dialog({
       close: function(event, ui) {
          event.preventDefault();
          //mycode              
          }
});

Even if i wrote the code above the dialog is closed bypassing my "preventDefault".

Thank you!

MV


I've been looking for an answer to this too - so far the best I've come up with is

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



$('.selector').bind('dialogbeforeclose', function(event,ui){
  alert('hello');
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜