Index: flag.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/Attic/flag.module,v
retrieving revision 1.1.2.71
diff -u -F^[^a-z]*function -r1.1.2.71 flag.module
--- flag.module	3 Dec 2008 12:55:25 -0000	1.1.2.71
+++ flag.module	5 Dec 2008 12:47:34 -0000
@@ -860,6 +860,11 @@ function flag_page($action, $flag_name, 
     print drupal_to_js(array(
       'status' => TRUE,
       'newLink' => $flag->theme($flag->is_flagged($content_id) ? 'unflag' : 'flag', $content_id, TRUE),
+      // Further information for the benefit of custom JavaScript event handlers:
+      'contentId' => $content_id,
+      'contentType' => $flag->content_type,
+      'flagName' => $flag_name,
+      'flagStatus' => $flag->is_flagged($content_id) ? 'flagged' : 'unflagged',
     ));
     exit;
   }
Index: theme/flag.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/theme/Attic/flag.js,v
retrieving revision 1.1.4.7
diff -u -F^[^a-z]*function -r1.1.4.7 flag.js
--- theme/flag.js	26 Nov 2008 22:51:44 -0000	1.1.4.7
+++ theme/flag.js	5 Dec 2008 12:47:34 -0000
@@ -15,7 +15,7 @@
    * @param element
    *   The <A> element.
    * @return
-   *   The new <A> elemenet.
+   *   The new link.
    */
   function updateLink(element, newHtml) {
     var $newLink = $(newHtml);
@@ -38,12 +38,12 @@   function updateLink(element, newHtml) 
     // Replace the old link with the new one.
     $wrapper.after($newLink).remove();
 
-    // So it won't crash on Drupal 5.
-    if (Drupal.attachBehaviors) {
+    if (Drupal.attachBehaviors) { // So it won't crash on Drupal 5.
       Drupal.attachBehaviors($newLink.get(0));
     }
 
     $('.flag-message', $newLink).fadeIn();
+    return $newLink.get(0);
   }
 
   /**
@@ -76,7 +76,12 @@   function flagClick() {
       success: function (data) {
         if (data.status) {
           // Success.
-          updateLink(element, data.newLink);
+          data.link = $wrapper.get(0);
+          $.event.trigger('flagGlobalBeforeLinkUpdate', [data]);
+          if (!data.preventDefault) { // A handler may cancel updating the link.
+            data.link = updateLink(element, data.newLink);
+          }
+          $.event.trigger('flagGlobalAfterLinkUpdate', [data]);
         }
         else {
           // Failure.
