When a jQuery UI dialog opens, it selects one of the buttons and highlights it or sets focus to it etc... How can I stop this behaviour so that none of the buttons are highlighted when the dialog opens?
EDIT: I tried the following in the dialog options, which didn't remove focus from the buttons:
...
open:function(event, ui) { $("myunimportantdiv").focus(); },
...
NOTE: As a temporary workaround I modified the CSS for .ui-state-focus
but this isn't ideal...
thanks for answers, but it seems to me that the best solution (at least for me, minimal code and no unnecessary use of methods on the DOM) is to define your dialog buttons in an array of object :
The important part to prevent your buttons to get focus is : tabIntex:-1
It is also a convenient and readable way to give id to your buttons.
This is the only way I got it working. tabIndex: -1 is the solution.
Oh, and I wanted to focus on the second button, so my "Delete Item?" confirmation would by default not delete the item.
Base on ED and Lev's answers, I got this good solution:
Use the blur method. You can try this sample.
Or, simply creating a dummy input before calling the other buttons works just as well. This works because the UI simply looks for the first "input" as the default, by tricking the UI into seeing a false input first, the focus is redirected.
I stumbled upon a little hack to fix this that others may find useful. A solution like this seems to work for me:
It simply programmatically sets it checked again, which seems to clear up the focus issue.