Overriding fetch() method in backbone model

后端 未结 1 1611
长发绾君心
长发绾君心 2021-02-18 15:04

I would like to override the default fetch() method in a Backbone model, thus calling it only when needed.

Something like this:

Account.Check = Backbone.         


        
1条回答
  •  后悔当初
    2021-02-18 15:35

    This should do it...

    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);    
               }
             }
    

    0 讨论(0)
提交回复
热议问题