2
我想为每个骨干类 - 模型,集合,路由器,视图添加自定义方法。我怎样才能做到这一点?backbone.js:如何向每个骨干类添加自定义方法
下面是我在做什么,直到如今....
Backbone.Router.prototype.method1 = function() {
console.log("I came here: router");
};
Backbone.View.prototype.method1 = function() {
console.log("I came here: view");
};
Backbone.Model.prototype.method1 = function() {
console.log("I came here: model");
};
Backbone.Collection.prototype.method1 = function() {
console.log("I came here: collection");
};
我猜必须有一个更好,更优雅的方式来做到这一点?
更新
这里是我是如何实现它最后。感谢有关记录@dira建议