.focus() not working on accordionchange event
Hi all, hope this is the right place for this. So I have an accordion inside of a modal dialog, used for sign in, registration, etc. Accordion has two parts, a sign in panel, and a registration panel.
On the user clicking the accordion and switching forms, say from sign in to registration, I am trying to .focus() on the first element in the form. Note that when the user launches the dialog, I am successfully able to set focus to the first element of the form, but as they switch panels I'd like to 'reset' focus to the now visible first form element.
First, I am binding the accordionchange event to the dialog itself, and then I am accessing the internal contents of the new accordion panel and trying to focus on the first element. Here is my code:
- $('#dialog').bind('accordionchange', function(event, ui) {
ui.newContent.find('input[type=text]:first').focus();
});
The problem I am having is that the input element is simply not 'focussed' on. I have tested that I am indeed accessing the correct element by switching out the .focus() call for .val('test'), and sure enough when I switch accordion panels, the first text input has a value of 'test' in it... any ideas?
Thanks!