我的控制器中有一个具有特定动作的Mixin.我需要覆盖此操作,执行一些操作,然后调用Mixin提供的原始操作.
我怎样才能做到这一点?
this._super() 在这种情况下似乎不起作用(这确实有意义,因为它意味着调用超类的实现,而不是Mixin的).
为了打电话this._super从Ember.run.next 尝试以下,
http://emberjs.jsbin.com/docig/3/edit
App.MyCustomMixin = Ember.Mixin.create({
testFunc:function(){
alert('original mixin testFunc');
},
actions:{
testAction:function(){
alert('original mixin testAction');
}
}
});
App.IndexController = Ember.Controller.extend(App.MyCustomMixin,{
testFunc:function(){
alert('overriden mixin testFunc');
var orig_func = this._super;
Ember.run.next(function(){
orig_func();
});
},
actions:{
test:function(){
this.testFunc();
},
testAction:function(){
alert('overriden mixin testAction');
var orig_func = this._super;
Ember.run.next(function(){
orig_func();
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3383 次 |
| 最近记录: |