Search code examples
jquerydrupaldrupal-6

Drupal - Drupal.settings values does not reload when validate fails


I have added the settings to my javascript file using this:

drupal_add_js(array('xc' => array('unit_descriptions' => $descriptions)), 'setting');
drupal_add_js(array('xc' => array('unit_names' => $units)), 'setting');

And it works fine when loading the .js file using:

$unitName.text(Drupal.settings.xc.unit_names[utid]);
$unitDesc.text(Drupal.settings.xc.unit_descriptions[utid]);

In order to load the values. But when validation fails, e.g: if I dont specify a name or whatever, these two arrays disappears and I get the statement in the console:

Drupal.settings.xc is undefined

How can I reload these arrays, or prevent the on validation fail to remove the arrays. Please, any help is appreciated.

Kind regards!


Solution

  • I solved it, in the validate function I just checked for any errors, and if an error exists, I just add the js files again.