One problem in drupal 6 with javascript is when you add configuration to jquery in function and this function is called two or more times. Instead of overwrite the configuration, drupal creates an array with the same configuration. One way to known if you added more than once your configuration is:
$js = drupal_add_js(NULL, NULL);
$found = FALSE;
if (!empty($js['setting'])) {
foreach ($js['setting'] as $key => $value) {
if (isset($value['example'])) {
$found = TRUE;
}
}
}
if (!$found) {
drupal_add_js(array('example' => array('lorem')), 'setting');
}
Add new comment