I made a module and wish to add js file to that module, I enable the module and obvious it works. But I didn't see the js file that module should take with.
I just put the code in the hook_menu() like this
function my2form_menu() {
drupal_add_js(drupal_get_path('module', 'my2form') . '/abc.js');
}
is it ok?
I made a module and wish to add js file to that module, I enable the module and obvious it works. But I didn't see the js file that module should take with.
I just put the code in the hook_menu() like this
function my2form_menu() {
drupal_add_js(drupal_get_path('module', 'my2form') . '/abc.js');
}
is it ok?
Share Improve this question asked May 19, 2012 at 17:58 user824624user824624 8,05035 gold badges120 silver badges210 bronze badges2 Answers
Reset to default 4If you plan to always include this JS file, you should add it in the .info file of your module: http://drupal/node/542202#scripts
And thus you can delete your hook_menu.
try another hook, called: modulename_js_alter()
works fpr my porposes.