diff --git a/src/eventsource.js b/src/eventsource.js index fc2a28aa..6d0d0870 100644 --- a/src/eventsource.js +++ b/src/eventsource.js @@ -67,10 +67,11 @@ $.EventSource.prototype = { */ addOnceHandler: function(eventName, handler, userData) { var self = this; - this.addHandler(eventName, function onceHandler(event) { + var onceHandler = function(event) { self.removeHandler(eventName, onceHandler); handler(event); - }, userData); + }; + this.addHandler(eventName, onceHandler, userData); }, /**