home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (batch.js)

This example Drupal source code file (batch.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

context, errorcallback, function, if, initmessage, op=do, pb, php, progress, return, status, updatecallback, uri, var

The batch.js Drupal example source code

// $Id: batch.js,v 1.4 2007/10/21 18:59:01 goba Exp $

 * Attaches the batch behavior to progress bars.
Drupal.behaviors.batch = function (context) {
  // This behavior attaches by ID, so is only valid once on a page.
  if ($('#progress.batch-processed').size()) {
  $('#progress', context).addClass('batch-processed').each(function () {
    var holder = this;
    var uri = Drupal.settings.batch.uri;
    var initMessage = Drupal.settings.batch.initMessage;
    var errorMessage = Drupal.settings.batch.errorMessage;

    // Success: redirect to the summary.
    var updateCallback = function (progress, status, pb) {
      if (progress == 100) {
        window.location = uri+'&op=finished';

    var errorCallback = function (pb) {
      var div = document.createElement('p');
      div.className = 'error';

    var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
    progress.setProgress(-1, initMessage);
    progress.startMonitoring(uri+'&op=do', 10);

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal batch.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.