在骨干模型压倒一切的fetch()方法 [英] Overriding fetch() method in backbone model
本文介绍了在骨干模型压倒一切的fetch()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想覆盖默认的fetch()方法中的骨干机型,因此只在需要时调用它。
I would like to override the default fetch() method in a Backbone model, thus calling it only when needed.
事情是这样的:
Account.Check = Backbone.Model.extend({
model : Account.Item,
url : Settings.Url.checkAccount,
fetch : function(options) {
if (someCondition()) {
// do some stuff
} else {
super.fetch(options);
}
}
});
我的问题是如何提供相同的行为作为默认fetch()方法中的 //做一些其他的东西的一部分?
推荐答案
这应该去做...
fetch : function(options) {
if (someCondition()) {
// do some stuff
} else {
this.constructor.__super__.fetch.apply(this, arguments);
// Or (less flexible)
Backbone.Model.prototype.fetch.apply(this, arguments);
}
}
这篇关于在骨干模型压倒一切的fetch()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文