Accessing parent class in Backbone

后端 未结 8 876
广开言路
广开言路 2020-12-07 14:40

I need to call the initialize method of the parent class, from inside the inherited MyModel-class, instead of completely overwriting it as I am doi

8条回答
  •  被撕碎了的回忆
    2020-12-07 15:02

    You might consider rewriting your code using functional inheritance.

    var BackBone=function(){
        var that={};
    
        that.m1=function(){
    
       };
       return that;
    
    };
    
    var MyModel=function(){
    
     var that=BackBone();
     var original_m1=that.m1;
    
    //overriding of m1
     that.m1=function(){
        //call original m1
     original_m1();
     //custom code for m1
      };
    };
    

提交回复
热议问题