By quercus020 on
Hey everybody!
I'm kinda new to adding jQuery stuff to Drupal websites. I'm not sure what the Drupal way of doing this is and I'm hoping someone can point me in the right direction.
I've got jQuery stuff working on my sites...but only by adding the jQuery and link to an external jquery.js file to the node itself. Nothing else seemed to work. Doesn't Drupal ship with jQuery itself?
I'd rather use the Drupal jQuery and have the files in a separate folder instead of in the node content.
Any pointers?
Cheers, Rob
Comments
Hello Rob, have you checked
Hello Rob,
have you checked at http://drupal.org/node/756722 ?
Toan,
No...I'd only found info for
No...I'd only found info for Drupal 5 and stuff.
Thanks very much.
jQuery and D7 themes
As to D7, the jQuery UI is now included in core.
This means for themers simply see if a JavaScript folder exists in your theme, i.e. look at xxx.info (xxx=your theme name) and how the scripts directive is set. Or add your own directive if none exists in xxx.info such as:
; Scripts
scripts[]=js/xxx.js
Then create a folder called js in your theme folder and put xxx.js in there.
Once that's done, go into xxx.js and add in any jQuery source within this wrapper code. for example:
Some folks like to put all this in a template folder in your theme, which is fine, too. Or in the theme main folder. Just remember to set the path correctly in xxx.info. You can add as many script files as you need if you're doing a complex project.