1

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?

2 Answers 2

4

If you plan to always include this JS file, you should add it in the .info file of your module: http://drupal.org/node/542202#scripts

And thus you can delete your hook_menu.

Sign up to request clarification or add additional context in comments.

Comments

2

try another hook, called: modulename_js_alter()

works fpr my porposes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.