I need to include jquery-1.10.2 for a module I am building in Drupal 7. The problem is, if I include the file with drupal_add_js in the module's .inc file, it causes the admin menu to display strange (there is no space reserved for it on the screen, so it is usually covered) I've gotten around this by calling drupal_add_js right inside the page callback function for the pages that need jquery. When I do this, the admin menu works fine, but if you click on any items shown in the overlay, the first time you click, there is a javascript error saying:
Uncaught TypeError: Cannot read property 'msie' of undefined
If you click the same button a second time, the overlay will load, but I need to fix this so that there aren't any bugs. I've done some research and it looks like this is because $.browser is depreciated as of 1.9.
So I was wondering if there is a way to include jS but to only have it applied to a specific function or maybe only to the 'content' div of the page? I did find hook_init which supposedly runs whatever commands are inside the function as the pages for that specific module are loaded, however it still seems to apply the include to all pages of my Drupal install.
<script>
tag inside a<div>
, but the global variables of the script are still global; therefore$
would be global too, and override the previously defined function. – kiamlaluno♦ May 23 '14 at 15:42