Answer: Use the ajax_load module http://drupal.org/project/ajax_load
Ajax Load was written to accompany a patch that added AJAX loading to the Views module. When enabled, Ajax Load will ensure that any needed JS and CSS files are loaded along with dynamically loaded views.
Issue summary:
When working with javascript that needs settings that will change depending on what happens with an AJAX enabled View, standards like drupal_add_js($myModulesSettings, "setting") will only work on a full page load, not an AJAX loaded View. I've resorted to adding javascript in a hook_form_alter()
$form['myModulesSettings'] = array(
"#value" => '<script type="text/javascript">Drupal.settings.myModulesSettings = ' . json_encode($myModulesSettings) . '; </script>';
);
I poked around the Views code and CTools but nothing jumped out at me. There must be a better way... Or we must create one.
Comments
Comment #1
merlinofchaos commentedIn Drupal 6 you can use the ajax_load module, I believe.
Comment #2
R.J. Steinert commentedThanks Earl, that looks like the ticket. From the project page:
Comment #2.0
R.J. Steinert commentedMore general example given.
Comment #3.0
(not verified) commentedPlacing the answer in the issue summary