I want to add javascript to a single page. In php block code using the existing module
<?php
drupal_add_js('js/leagueSettings.js');
?>
I have a js folder in the modules/php directory where this specific module is.
I have tried using script tags also to no avail.
<script type = "text/javascript" src = "js/leagueSettings.js"></script>
leagueSettings.js is simply
(function ($) {
alert('here');
})(jQuery);
I have tried it with only the alert..doesn't matter. I have tried using the DIR magic constant in place of the path.. nothing.
Anything I am missing?
EDIT---SOLUTION
//becuase the php block is 'php' module...
drupal_add_js(drupal_get_path('module', 'php') .'/js/leagueSettings.js');
drupal_add_js()
in your code? As in, what function or hook? Also, be sure to read the documentation very carefully api.drupal.org/api/drupal/includes%21common.inc/function/… – kevin628 Jun 12 '12 at 19:24