jsbin示例:http://jsbin.com/ICoLOgO/4/edit
如果我有一个提供动作的mixin,使用ember 1.0-rc.5,则该动作将被调用而不会发出警告。升级到ember 1.0 final会导致弃用警告显示:
Action handlers implemented directly on controllers are deprecated in favor of action handlers on an `actions` object
有没有一种更简单的方法可以在无需使用function.apply的情况下在操作图中显示单个操作?
我只是将普通操作actions
放在混合表的哈希中,Ember负责将操作散列与扩展混合表的任何控制器正确合并。
App.PaginatedListController = Ember.Mixin.create({
queryParams: ['page'],
page: 0,
actions: {
nextPage: function() {
this.incrementProperty('page');
},
previousPage: function() {
this.decrementProperty('page');
},
}
});
App.PostsController = Ember.ArrayController.extend(App.PaginatedListController, {
actions: {
// controller specific actions here
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句