2

I have code to open a jQueryUI dialog with two buttons (OK, and Cancel). When the dialog opens, I want the OK button to have focus by default. After that, when I press the ENTER key, it should perform the actions associated with the OK button. How do I make this happen?

Agi Hammerthief
  • 2,114
  • 1
  • 22
  • 38
Poonam Bhatt
  • 10,154
  • 16
  • 53
  • 72

1 Answers1

4

Use this code:

open: function() {
        $(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button:eq
(1)').focus();
        $(this).closest('.ui-dialog').find('.ui-dialog-buttonpane button:eq
(0)').blur();
}, 
halfer
  • 19,824
  • 17
  • 99
  • 186
  • see this link http://stackoverflow.com/questions/1793592/jquery-ui-dialog-button-focus it will be help full to you.. –  Mar 12 '12 at 12:06
  • @PoonamBhatt if u done with u r problem....than make it as answer..so that anyone can refer it.... –  Mar 12 '12 at 17:31