I ran into this trouble:

I want to use javascript to modify the display of one module (module1) from another module (module2). That is to say, module2 has a couple of .js files and maybe a sort of "hook_theme_alter" function that are used to modify the display of some widgets in module1. module1, however, does not know the existence of module2. I cannot see the hook_theme_registry_alter can do this job.

Thanks a lot.

Comments

Jaypan’s picture

Javascript doesn't care what module it comes from. Just include the JS file on the page it needs to be included on, and it will execute.

gracefulpig’s picture

Thank you Jaypan. The thing was, drupal runs to module2, which processes something, and then is redirected to the page generated by module1. So when the module1 was running, how the javascripts can be loaded from module2? In other words, how can module2 notice when the module1 is running and then add javascripts in itself module to the pages generated by module1?

Jaypan’s picture

Your question is too generic to understand. Please explain specifically what you are trying to do, and what is not working.

gracefulpig’s picture

Sorry about the confusion. I just figure it out by myself, using the module_preprocess_hook function.

Thanks.