You may also use :first instead of :last depending on which button you want to set as the default.This solution, compared to the selected one above, has the advantage of showing which button is the default one for the user.I assume this might be a simple option with the dialog, but I can't find it in the j Query UI documentation.I could bind each form input with keyup() but didn't know if there was a simpler/cleaner way. This'll run no matter what element has the focus in your dialog, which may or may not be a good thing depending on what you want.
In other words, I want it to act like a regular GUI dialog box where simulates hitting the "OK" button.
but i can't understand how it's working without the trigger!
probably u have another event bind that do the same It works beautifully with the latest version of JQuery UI (1.8.1).
I think there should be a .first() in there as in $('.ui-dialog').find('button').first().trigger('click'); Otherwise you'll trigger the click of all the buttons of the dialog if there are more than one.
Ben Clayton's is the neatest and shortest and it can be placed at the top of your index page before any jquery dialogs have been initialized.
If you only want this behavior when the button is actually focused, my answer is too complicated.