? .komodotools
? 769258.ajax-bind-once.35.patch
? d7dec10.komodoproject
? sites/all/modules/contrib
? sites/default/files
? sites/default/settings.php
Index: misc/ajax.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/ajax.js,v
retrieving revision 1.35
diff -u -p -r1.35 ajax.js
--- misc/ajax.js	23 Dec 2010 04:26:31 -0000	1.35
+++ misc/ajax.js	10 Jan 2011 04:20:18 -0000
@@ -30,6 +30,11 @@ Drupal.behaviors.AJAX = {
         }
         $(element_settings.selector).each(function () {
           element_settings.element = this;
+
+          // Check whether to bind behaviors using .one() instead of .bind().
+          if ($(this).hasClass('ajax-once')) {
+            element_settings.bindMethod = 'one';
+          }
           Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
         });
 
@@ -49,6 +54,10 @@ Drupal.behaviors.AJAX = {
         element_settings.url = $(this).attr('href');
         element_settings.event = 'click';
       }
+      // Check whether to bind behaviors using .one() instead of .bind().
+      if ($(this).hasClass('ajax-once')) {
+        element_settings.bindMethod = 'one';
+      }
       var base = $(this).attr('id');
       Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
     });
@@ -174,11 +183,24 @@ Drupal.ajax = function (base, element, e
     type: 'POST'
   };
 
-  // Bind the ajaxSubmit function to the element event.
-  $(ajax.element).bind(element_settings.event, function (event) {
+  // By default, behaviors are bound using .bind().
+  if (!element_settings.bindMethod) {
+    element_settings.bindMethod = 'bind';
+  }
+
+  // Bind the handler to the element event using whichever bind method was set.
+  $(ajax.element)[element_settings.bindMethod](element_settings.event, function (event) {
     return ajax.eventResponse(this, event);
   });
 
+  // If the behavior was only bound once, the browser's default behavior needs
+  // to be prevented on subsequent events, so as to not follow links.
+  if (element_settings.bindMethod == 'one') {
+    $(ajax.element).bind(element_settings.event, function () {
+      return false;
+    });
+  }
+
   // If necessary, enable keyboard submission so that AJAX behaviors
   // can be triggered through keyboard input as well as e.g. a mousedown
   // action.
