开发者

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

开发者 https://www.devze.com 2023-01-18 23:49 出处:网络
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'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

精彩评论

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