[support] Guide on how to set up JS in drupal7?

Jacob Roufa jacob.roufa at gmail.com
Sat Mar 17 03:03:12 UTC 2012


While the declaration of how a script must be wrapped in a jQuery function
- (function($) { stuffHere })(jQuery); - holds true for Drupal 7, the
proper way to include a script in a theme is definitely to use the theme's
info file. Personally, one of the first things I do when writing a theme is
to make a script.js that holds all of my custom one-off scripts (such as
show/hide functionality). This method is not limited to including custom
scripts; I also use this to include jQuery plugins that don't currently
have Drupal equivalents.

Jake Roufa
208.557.9390
about.me/jacobroufa



On Fri, Mar 16, 2012 at 8:35 PM, Anthony <tony at tony-mac.com> wrote:

> That's sort of what I figured would be the way to do it.
> I found this page
> http://renaudjoubert.com/en/article/how-add-javascript-drupal-7-jquery
> I was rather confused by this text  (partial quote) *"In the present
> case, the next best way - a proper way - is to embed the script directly
> into the Article template of the theme. In doing so, the script will be
> available for all nodes created with the Article content type. Now, that's
> even better. So how do we do this?" *
>
> I thought that sounds rather cumbersome.
>
> That's when I thought I must ask.
> Tony
>
>
> On Fri, Mar 16, 2012 at 5:11 PM, Jacob Roufa <jacob.roufa at gmail.com>wrote:
>
>> In your theme's info file, put the location/name of your custom .js below
>> any other scripts. Clear your theme cache and it should take effect.
>>
>> http://drupal.org/node/171205#scripts
>>
>> Everything else about a theme's info file, such as adding more
>> stylesheets or various other features, is also on this page.
>>
>> Jake Roufa
>> 208.557.9390
>> about.me/jacobroufa
>>
>>
>>
>> On Fri, Mar 16, 2012 at 6:03 PM, Anthony <tony at tony-mac.com> wrote:
>>
>>>  before I start searching away. How to best use JS in Omega? How to
>>> integrate some JQuery in Drupal 7 and Omega? Is there an article that
>>> quickly comes to mind. Thanks for any tips.
>>> Tony
>>>
>>> --
>>>
>>> *Anthony Stefan Maciejowski*
>>>
>>> *tony maciejowski** | analyst/programmer  | websites | www.tony-mac.com<t_maciejowski at hotmail.com>
>>> *
>>>
>>> *Twitter: anntosh* | *Cell: 323.899.6206* | *Linked-In:* *Anthony
>>> Maciejowski*
>>>
>>>  “Hope is not the conviction that something will turn out well, but the
>>> certainty that something makes sense, regardless of how it turns out.”
>>>
>>> --- Vaclav Havel
>>>
>>>
>>>
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
>
> --
>
> *Anthony Stefan Maciejowski*
>
> *tony maciejowski** | analyst/programmer  | websites | www.tony-mac.com<t_maciejowski at hotmail.com>
> *
>
> *Twitter: anntosh* | *Cell: 323.899.6206* | *Linked-In:* *Anthony
> Maciejowski*
>
>  “Hope is not the conviction that something will turn out well, but the
> certainty that something makes sense, regardless of how it turns out.”
>
> --- Vaclav Havel
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120316/88302c0c/attachment.html 


More information about the support mailing list