Your event handler is not set up correctly. It is called immediately rather than set up to be called when the event occurs. You can change it to this:
var MyFancyObject = {
init: function() {
// set controls
this.abc = // load some stuff async
var self = this;
this.select.on('change', function(e) {
self.myEvent(e);
}); // attach my event
},
myEvent: function() {
console.log(this.abc); // undefined
}
};
Or, in modern browsers (IE9 or higher), you could use .bind()
.
var MyFancyObject = {
init: function() {
// set controls
this.abc = // load some stuff async
this.select.on('change', this.myEvent.bind(this)); // attach my event
},
myEvent: function() {
console.log(this.abc); // undefined
}
};