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

i'm using JQuery-ui dialog;i'd like to perform my custom actions when user clicks on dialog&#

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" ).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'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" ).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

Share Improve this question asked Oct 5, 2010 at 14:35 MircoMirco 1892 silver badges10 bronze badges 1
  • maybe return false; ? :) Or just hide [x] button and add your own cancel button – Danil Commented Oct 5, 2010 at 14:38
Add a ment  | 

2 Answers 2

Reset to default 6

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

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742350597a4427437.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信