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
2 Answers
Reset to default 6I'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');
});