[ADD] Added trigger_children and trigger_ancestors in corelib EventDispatcherMixin

bzr revid: fme@openerp.com-20120906101547-2fa0r9d0lqhzzemi
This commit is contained in:
Fabien Meghazi 2012-09-06 12:15:47 +02:00
parent a01a27e480
commit c58b567d94
1 changed files with 20 additions and 0 deletions

View File

@ -359,6 +359,26 @@ instance.web.EventDispatcherMixin = _.extend({}, instance.web.ParentedMixin, {
this.__edispatcherEvents.trigger.apply(this.__edispatcherEvents, arguments);
return this;
},
trigger_children: function(events) {
var children = this.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.__eventDispatcherMixin) {
child.__edispatcherEvents.trigger.apply(child.__edispatcherEvents, arguments);
child.trigger_children.apply(child, arguments);
}
}
return this;
},
trigger_ancestors: function(events) {
var parent = this;
while (parent = parent.getParent()) {
parent.__edispatcherEvents.trigger.apply(parent.__edispatcherEvents, arguments);
parent.trigger_ancestors.apply(parent, arguments);
}
return this;
},
destroy: function() {
var self = this;
_.each(this.__edispatcherRegisteredEvents, function(event) {