O'Reilly logo

Drupal 7 Module Development by Ken Rickard, John Wilkins, Larry Garfield, Matt Butcher, Greg Dunlap, Matt Farina

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drupal specific JavaScript

Within Drupal there are numerous helper functions. These range from systems like theming and translation to utility functions that parse JSON.

Themeable presentation

The entire presentation inside of Drupal is customizable through the theme system, and JavaScript is no different. Drupal provides a system for theming the presentation generated by the JavaScript that can be overridden within JavaScript in a theme. We can start with an example, hello_world.js, that is added by a module that looks like this:

(function($) {
$().ready(function() {
$('#hello-world').html('<h2>Hello World!</h2>');
});
})(jQuery);

When the page is loaded, the html inside the div with the ID hello-world will be replaced with<h2>Hello World!</h2> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required