diff --git a/source/Ox.UI/js/Core/Event.js b/source/Ox.UI/js/Core/Event.js index 245d11ca..2ba5e409 100644 --- a/source/Ox.UI/js/Core/Event.js +++ b/source/Ox.UI/js/Core/Event.js @@ -120,10 +120,13 @@ Ox.Event = (function() { data Event data */ that.trigger = function(self) { - var element = this; - if (self.eventHandlers) { - Ox.forEach(Ox.makeObject(Ox.slice(arguments, 1)), function(data, event) { + var args = arguments, element = this; + self.eventHandlers && setTimeout(function() { + Ox.forEach(Ox.makeObject(Ox.slice(args, 1)), function(data, event) { var triggered = event.split('.'); + eventHandlers.forEach(function(callback) { + callback.call(element, data || {}, event, element); + }); triggered.map(function(v, i) { return triggered.slice(0, i + 1).join('.'); }).concat('*').forEach(function(triggered) { @@ -133,11 +136,8 @@ Ox.Event = (function() { handler.callback.call(element, data || {}, event); }); }); - eventHandlers.forEach(function(callback) { - callback.call(element, data || {}, event, element); - }); }); - } + }); return that; }; @@ -166,7 +166,7 @@ Ox.Event = (function() { if (args.length == 0) { eventHandlers = []; } else if (Ox.isFunction(args[0])) { - eventHandlers.forEach(function(handler) { + eventHandlers.forEach(function(handler, i) { handler === args[0] && eventHandlers.splice(i, 1); }); } else if ((self = args.shift()).eventHandlers) {