I have a jQuery UI dialog box with a form. I would like to simulate a click on one of the dialog’s buttons so you don’t have to use the mouse or tab over to it. In other words, I want it to act like a regular GUI dialog box where simulates hitting the “OK” button.
I assume this might be a simple option with the dialog, but I can’t find it in the jQuery UI documentation. I could bind each form input with keyup() but didn’t know if there was a simpler/cleaner way. Thanks.
I don’t know if there’s an option in the jQuery UI widget, but you could simply bind the
keypressevent to the div that contains your dialog…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.
If you want to make this the default functionality, you can add this piece of code:
Here’s a more detailed view of what it would look like: