Inside a YUI view I have the following methods:
initializer: function () {
this.after('init', this.onInitComplete, this);
},
onInitComplete: function (e) {
console.log('onInitComplete');
var list = this.checkGroupList = new CheckGroupList();
var group1 = new Y.CheckGroupModel();
var group2 = new Y.CheckGroupModel();
var group3 = new Y.CheckGroupModel();
list.add(group1);
list.add(group2);
list.add(group3);
this.reset();
},
Why onInitComplete is not running?
The reason your listener isn't being called is that YUI is trying to optimize the init
event because it is too expensive when creating lots of instances of Y.Base
. The init
event s normally responsible for calling all the initializers. But when there are no listeners the initializer functions are called directly without firing the init
the event. Since you're adding a listener in an initializer, YUI assumes there are no listeners to the event and doesn't fire it.
I suggest you either do what you were doing in the listener directly in the initializer or add a listener to the event from the class constructor.