[jQuery] prompt before closing dialog
Hi, i'm having some trouble because i'm using a dialog witch has a form in it where someone can change info about their hotel. this dialog also has 2 buttons one to close and the other to save changes. what i'm trying to accomplish is - when someone made sany change and tries to close de dialog without saving he will be prompt if he really wants to leave without saving the changes an the dialog only closes if person choses 'yes'. when closing the window clicking the 'close' button i can accomplish this, but i wanted it also to work when closing dialog using the x button on the top of the dialog. is this possible?
Re: [jQuery] prompt before closing dialog
If you provide your function for the close event you should be able to achieve this. It should return false in case you don't want it to close (in my opinion) Thanks Regards, Dhruva Sagar. On Thu, Dec 17, 2009 at 3:40 PM, Obi1 gurreiro_fa...@yahoo.com.br wrote: Hi, i'm having some trouble because i'm using a dialog witch has a form in it where someone can change info about their hotel. this dialog also has 2 buttons one to close and the other to save changes. what i'm trying to accomplish is - when someone made sany change and tries to close de dialog without saving he will be prompt if he really wants to leave without saving the changes an the dialog only closes if person choses 'yes'. when closing the window clicking the 'close' button i can accomplish this, but i wanted it also to work when closing dialog using the x button on the top of the dialog. is this possible?
Re: [jQuery] prompt before closing dialog
Handle the beforeclose event and return false if you don't want to allow the dialog to close yet: http://docs.jquery.com/UI/Dialog#event-beforeclose If you have any further questions, there's a separate list for questions about jQuery UI plugins: http://groups.google.com/group/jquery-ui - Richard On Thu, Dec 17, 2009 at 5:10 AM, Obi1 gurreiro_fa...@yahoo.com.br wrote: Hi, i'm having some trouble because i'm using a dialog witch has a form in it where someone can change info about their hotel. this dialog also has 2 buttons one to close and the other to save changes. what i'm trying to accomplish is - when someone made sany change and tries to close de dialog without saving he will be prompt if he really wants to leave without saving the changes an the dialog only closes if person choses 'yes'. when closing the window clicking the 'close' button i can accomplish this, but i wanted it also to work when closing dialog using the x button on the top of the dialog. is this possible?
Re: [jQuery] prompt before closing dialog
in your buttons definition: buttons : { Close : function () { if (!formChanged()) { $(#myDialog).dialog(close); } else { $(#confirm).dialog(open); } } } $(#confirm).dialog({ buttons: { Yes : function () { $(#confirm).dialog(close); $(#myDialog).dialog(close); }, No : function () { $(#confirm).close(); } } }); One approach. Haven't tested this any though... :) Shawn Obi1 wrote: Hi, i'm having some trouble because i'm using a dialog witch has a form in it where someone can change info about their hotel. this dialog also has 2 buttons one to close and the other to save changes. what i'm trying to accomplish is - when someone made sany change and tries to close de dialog without saving he will be prompt if he really wants to leave without saving the changes an the dialog only closes if person choses 'yes'. when closing the window clicking the 'close' button i can accomplish this, but i wanted it also to work when closing dialog using the x button on the top of the dialog. is this possible?