December 2013

So it turns out jquery is easy. I can't believe I have gone this long as a Drupal themer and not bothered to try jquery. I saw all these $ and () and just figured it would be complicated.

Well I been messing around on jsfiddle.net, making some pretty interesting things - ex. http://jsfiddle.net/tesliker/L9uPm/3/ , but then I turned my sights back to integrating this with Drupal. This is where I had some trouble. Besides the fact I always forget to run cron after adding new JS and CSS stylesheets, it turns out you have to wrap your jquery in a special wrapper so that the $ variable does not confuse Drupal. Anyways, here is what I ended up doing to get this up and running correctly.

I added my custom module.

I named it custom_js, and added custom_js.info with the following code:

name = Custom JS

description = Add your custom Javascript files here.

package = Custom Modules

core = 7.x

I then added a custom_js.module file with the following code:

<?php

Read More...