This document discusses jQuery and how it can be used with Drupal. It provides an overview of jQuery, what it is best at doing, how to add jQuery to a Drupal theme, common AJAX use cases, and popular jQuery modules for Drupal. It also briefly discusses jQuery UI and resources for working with jQuery.
4. Why is it so fun?
• Removes cross-browser pain
• Leverages your existing CSS knowledge
• Animates elements on the page
• Compact code
5. What’s it best at?
• Adding/Removing elements to/from the
page
• Hiding/Showing elements
• Animating CSS transitions
• Responding to clicks, hovers, focus events
• Selecting from and traversing the DOM
6. Core Drupal jQuery
• Drupal adopted jQuery into core starting
with Drupal 5
• In /misc: drag-and-drop ordering,
expandable textareas, collapsible fieldsets,
autocomplete, persistent table headers etc.
8. Adding jQuery to a
theme
• drupal_add_js(drupal_get_path(‘theme’,
‘MYTHEME’) . ‘/js/myfile.js’, ‘theme’);
• Add this to the top of template.php or in a
specific theme function
16. Common Use Cases
• Show more content on a page with hide/
show, tabs, accordions, rotators, modals
• Search bar with disappearing default value
• Slicker functionality with AJAX and AHAH