Author: mgrigorov
Date: Wed Oct 12 11:33:46 2011
New Revision: 1182315

URL: http://svn.apache.org/viewvc?rev=1182315&view=rev
Log:
WICKET-4122 Event listener not properly detached for multipart AJAX requests


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1182315&r1=1182314&r2=1182315&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
(original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
Wed Oct 12 11:33:46 2011
@@ -1212,7 +1212,8 @@ Wicket.Ajax.Call.prototype = {
                
                // install handler to deal with the ajax response
                // ... we add the onload event after form submit because chrome 
fires it prematurely
-               Wicket.Event.add(iframe, "load", 
this.handleMultipartComplete.bind(this));
+               this.handleMultipartCompleteBound = 
this.handleMultipartComplete.bind(this);
+               Wicket.Event.add(iframe, "load", 
this.handleMultipartCompleteBound);
 
                // handled, restore state and return true
                form.action=originalFormAction;
@@ -1243,11 +1244,15 @@ Wicket.Ajax.Call.prototype = {
                if (event.stopPropagation) { event.stopPropagation(); } else { 
event.cancelBubble=true; }
 
                // remove the event
-               if (iframe.detachEvent)  
-                       iframe.detachEvent("onload", 
this.handleMultipartComplete);  
-               else  
-                       iframe.removeEventListener("load", 
this.handleMultipartComplete, false);
-               
+               if (typeof (this.handleMultipartCompleteBound) === 'function') {
+                       if (iframe.detachEvent) {
+                               iframe.detachEvent("onload", 
this.handleMultipartCompleteBound);
+                       }
+                       else {
+                               iframe.removeEventListener("load", 
this.handleMultipartCompleteBound, false);
+                       }
+                       this.handleMultipartCompleteBound = null;
+               }
                // remove the iframe and button elements
                setTimeout(function() {
                        var e=document.getElementById(iframe.id+"-btn");


Reply via email to