I just found an issue with gmap_location module (submodule from GMap Module) which integrated Location module to create location picker from Google Maps API.
This issue is when I've setup location field as multiple values, map will appeared "Javascript is required to view this map." with some javascript errors after I clicked "Add another item" button.
I've spent some times and found root of problem. Because gmap_location module will add gmap init javascript when it would be rendered, so their map settings will never be added with drupal_add_js() because:
In cck/includes/content.node_form.inc > content_add_more_js($type_name_url, $field_name) (before the end of function)
// If a newly inserted widget contains AHAH behaviors, they normally won't
// work because AHAH doesn't know about those - it just attaches to the exact
// form elements that were initially specified in the Drupal.settings object.
// The new ones didn't exist then, so we need to update Drupal.settings
// by ourselves in order to let AHAH know about those new form elements.
$javascript = drupal_add_js(NULL, NULL);
$output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
$output = theme('status_messages') . drupal_render($field_form) . $output_js;
$javascript would get javascript settings before drupal_render() would be called so gmap init script would not load yet.
So I've modified some code to:
// If a newly inserted widget contains AHAH behaviors, they normally won't
// work because AHAH doesn't know about those - it just attaches to the exact
// form elements that were initially specified in the Drupal.settings object.
// The new ones didn't exist then, so we need to update Drupal.settings
// by ourselves in order to let AHAH know about those new form elements.
$form = drupal_render($field_form); // Render form before load javascript so other modules could add own js correctly.
$javascript = drupal_add_js(NULL, NULL);
$output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
$output = theme('status_messages') . $form . $output_js;
In this way, other modules may include their own javascript with drupal_add_js() that affected to AHAH callback too.
This approch maybe suit only my situation (and I have to fix some javascript code in gmap module too for working as I expected), so please review and fix issue in the proper way.
Thank you.