I'm trying to figure out how to use this._super
when the Ember's object method is called from a callback.
I know that I could assign var _super = this._super
before the callback is called but I don't like it.
I want to have the this
object containing proper _super
method inside the callback.
My code is here: http://emberjs.jsbin.com/hasehija/6/edit.
App.BaseMixin = Ember.Mixin.create({
init: function() {
console.log("base");
}
});
App.Utils = Ember.Object.extend({
callbackMethod: function(callback, ctx) {
// asynchronous callback
Ember.run(function() {
callback.call(ctx);
});
}
});
App.MyObject = Ember.Object.extend(App.BaseMixin, {
init: function() {
console.log("MyObject");
var _super = this._super;
App.Utils.create().callbackMethod(function() {
this._super(); // this._super is undefined here
// _super() would work
}, this);
}
});
App.ApplicationController = Ember.Controller.extend({
init: function() {
new App.MyObject();
}
});
Do you know any way to fix it?
UPDATE:
It turned out that it was fixed in Ember 1.5.0 (@GJK: thank you for the answer) and I was using Ember 1.4.0.
extend
defines a classcreate
builds an instance of the classor
http://emberjs.jsbin.com/hasehija/7/edit
Or avoid overriding init