This page is archived
We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.
Alternate resources
Learn how to integrate jQuery scripts into Drupal, and how to leverage the JavaScript capabilities of the Drupal API in both 6.x & 7.x
If you've been itching to add more whiz-bang excitement to your Drupal website but felt like you just don't understand all this Ajax/JavaScript stuff, then this series is for you! This series builds off of concepts covered in videos such as Theming Basics, Advanced Theming, Drupal Module Development and Introduction to jQuery. This Series ties together these concepts as we delve into Drupal's JavaScript and Ajax APIs.
jQuery & Javascript in Drupal carefully walks you through all of the Drupal-specific JavaScript conventions that you'll need to know to begin integrating jQuery scripts into your Drupal 6 or Drupal 7 websites. You'll get a brief introduction to jQuery and learn how to add JavaScript code through the theme layer as well as via a module. You'll also learn how to pass variables from PHP into your JavaScript files through the Drupal-specific Drupal.settings variable.
We've written six example modules in this video and we walk you through each one in order to demonstrate how to integrate jQuery scripts into your Drupal website. This hands-on approach will help you learn how to leverage Drupal's JavaScript-related Form API properties, how to create sortable table forms, and how to leverage the AHAH framework in Drupal 6 as well as the powerful Ajax framework in Drupal 7. This video will teach you everything you need to know to start creating fully Ajax-enabled Drupal websites. In this video we also explore the new JavaScript states system in Drupal 7, which allows you to create dynamic form dependencies and increase the usability of forms in Drupal. Finally, we'll take a look at some of the ways to keep your jQuery version up to date and some of the other popular JavaScript-related Drupal contributed modules.
Note: The examples in the video span across Drupal 6 and Drupal 7, and jQuery code that will work either in jQuery version 1.2.6 or 1.4.
The example module files used in this video can be downloaded here.
Learn how to integrate jQuery scripts into Drupal, and how to leverage the JavaScript capabilities of the Drupal API in both 6.x & 7.x
Jeff Robbins and Nate Haug introduce the jQuery and Drupal integrations that we'll be building in this series, based on the foundations of theming, module development, and jQuery.
- How to add jQuery to a theme
- How to utilize Drupal's drag and drop behavior to reorder elements on a page within any form that has orderable items
- Drupal's direct integration with jQuery through the Forms API in Drupal 6 and Drupal 7
- Building a highly optimized AJAX request to Drupal that will return a JSON result
- The JavaScript state system in Drupal 7
Note: The examples in the video span across Drupal 6 and Drupal 7, and jQuery code that will work either in jQuery version 1.2.6 or 1.4.
jQuery Overview
FreeProvides a high-level overview of jQuery to people who are brand new to this JavaScript library.
This lesson shows the steps and code to add on the Drupal side in order to load JavaScript scripts to you site. One thing to note is that the HTML5 placeholder attribute makes this plugin invalid markup.
NOTE:
There is a minor change between Drupal 6 and Drupal 7, where you should use function($)
to wrap your code. For Drupal 7 you can use:
(function($) {
$(document).ready(function() {
$('#search input.form-text').autofill({
value: Drupal.t('Search...'),
});
});
}(jQuery));
Goes over the Macro Maker demonstration module in order to show what functionality we will be building over the next couple of chapters.
Shows how to pass variables from the PHP and Drupal side over to the front-end JavaScript scripts that are running so that you can use the Drupal interface to create customized settings that will appear in your jQuery scripts.
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: http://drupal.org/update/modules/6/7#drupal_behaviors
And more general information about using the new system here http://drupal.org/node/756722
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.
Shows the steps involved in converting a regular table into a table that is sortable by columns that you specify.
A review of the Form API properties that provide interactive user interface elements by automatically adding JavaScript behaviors to the form elements.
Goes through how to implement the AHAH framework in Drupal 6 in order to provide more dynamic interactions on a Drupal form.
See how the new JavaScript APIs and ajax framework in Drupal 7 allows you to implement dynamic behaviors without having to register a menu callback in the menu system or to write any jQuery code.
Shows how you can use the ajax framework in Drupal 7 to load additional content onto the page dynamically after clicking on a 'read more' link.
The sample code for this series is in the Downloads tab for the first video in this series: http://drupalize.me/videos/introduction-jquery-and-javascript-drupal#do…. If you're skipping around, and things aren't working, you may benefit from going back to the beginning and completing each of the videos in order.
Create dependencies between form elements so that you can show/hide or disable/enable one form setting based upon the form state of another from setting.
Go on a brief tour of other jQuery and JavaScript-related contributed modules that are worth knowing about.
A review of all of the material covered within the jQuery & JavaScript in Drupal series.