Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Drupal.behaviors and Drupal-specific JavaScript

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:15
    Now that our JavaScript is added to the page,
  • 0:17
    let's take a look at some of the code
  • 0:19
    and see how Macro Maker is actually functioning.
  • 0:22
    To start things off, we'll go to a page
  • 0:24
    that Macro Maker is active such as a node edit form.
  • 0:28
    And then we'll scroll down to the form, click inside of the body,
  • 0:32
    and then open up our Macro Maker window and insert a macro.
  • 0:38
    Pretty cool.
  • 0:39
    Operating exactly the way we want it to.
  • 0:42
    So let's go and take a look at the code and see how this is all built.

Drupal.behaviors and Drupal-Specific Javascript


Goes into depth about some of the JavaScript constructs and tools that Drupal provides when writing JavaScript for Drupal. Topics include using Drupal.behaviors and variable settings.

There where a couple of changes to the Drupal.behaviors system for D7. You can find out more information about the changes here:

And more general information about using the new system here

Once you've converted from the old Drupal.behaviors.myModule = function(context) to the new syntax

Drupal.behaviors.myModule = {
attach: function(context, settings),
detach: function(context, settings)

The rest is pretty much the same.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.