I have working code in my theme's template.php file that adds "autofocus" to my modal login form, but Firefox ignores ajax autofocus fields (only applies autofocus on pageload). So I'm trying to add some js to set focus when the modal login form is called. I currently add autofocus via:
function mytheme_preprocess_user_login(&$variables) {
$variables['form']['name']['#attributes']['autofocus'] = array('autofocus');
$variables['rendered'] = drupal_render_children($variables['form']);
}
And I'm trying to add js to set focus as a fallback this way:
function mytheme_preprocess_user_login(&$variables) {
$variables['form']['name']['#attributes']['autofocus'] = array('autofocus');
$variables['form']['#attached'][js][] = path_to_theme() . "/js/focus.js";
$variables['rendered'] = drupal_render_children($variables['form']);
}
but this doesn't seem to add the js as expected. How can I add either inline or external javascript to my modal login form?