Dialogs are essentially asynchronous so the confirm function is
returning before the user clicks either button.  You need to put the
logic for what to do inside the button functions.

On Dec 16, 4:16 pm, Carl Von Stetten <[email protected]> wrote:
> I'm trying to replace the standard browser confirm() function with a
> custom one based on ui.dialog.  Here is the function:
>
> function confirm(msg) {
>         var response = false;
>         // Create the confirm dialog box and open it
>         $("#confirm_dialog")
>                 .html('<p>'+msg+'</p>')
>                 .dialog({
>                         modal: true,
>                         title: "Confirmation Required",
>                         closeOnEscape: false,
>                         open: function() {
>                                         
> $(document).unbind('keydown.dialog-overlay');
>                                 },
>                         buttons: {
>                                 "OK": function() {
>                                         $(this).dialog("close");
>                                         $(this).dialog("destroy");
>                                         response=true;
>                                 },
>                                 "Cancel": function() {
>                                         $(this).dialog("close");
>                                         $(this).dialog("destroy");
>                                         response=false;
>                                 }
>                         }
>                 });
>         return response;
>
> }
>
> As you can see, the intent is that if the OK button is clicked, the
> function returns true, and if Cancel is clicked, the function returns
> false.  However, this is not working.  The value of response is not
> being changed by the ui.dialog buttons callbacks.  What am I doing
> wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to