I have a jquery UI dialog with two buttons: OK and Cancel.  When the
dialog opens, I want the OK button to be in focus.  Here is my code:

$('#confirmationDialog').dialog({
        autoOpen: false,
        width: 400,
        height: 200,
        draggable: false,
        resizable: false,
        modal: true,
        closeOnEscape: false,
        bgiframe: true,
        buttons: {
                "Cancel": function() {
                        $(this).dialog("close");
                },
                "OK": function() {
                        window.location = 'somepage.html';
                }
        }
});

It seems that the jquery UI dialog puts the first defined button (in
my case, the "Cancel" button) in focus by default.  But I want the
second button (the "OK" button) to be in focus.

I do not want to change the order of the definition of the buttons,
because I want the OK button to be on the left, and the buttons
floated right (as they are by default).

I have read elsewhere on the internet that a fix is to add the
following to my dialog definition:

open: function() {
        $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
},

However, I can not get this to work (no matter if I use eq(0), eq(1),
or eq(2)).

Any ideas would be greatly appreciated.  Thanks,

-Tim

--~--~---------~--~----~------------~-------~--~----~
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