I add js file with drupal_add_js
in hook_form_alter
, it is ok and I see it in list of js loaded in page, but when I submit form and form not validate and return to that form (after validation failed) I don't see js files that added to form, why this happened? and how can add my js file in that form after validation failed ?
some part of my code
function mymodle_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'news_node_form') {
drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodulejsfile.js'); //, array('scope' => 'footer','weight' => 10));
}
}
code work correctly in add and edit form, but when form submit and validation failed it show validation error but my js file not loaded in page (I checked html source and check firebug script files), but there is not my js file,
hook_form_alter
but when validation failed that js files not loaded in browser, it means that only in first load of page drupal_add_js taked effect I update question with more descrption.