超模型的骨干性质

时间:2013-09-26 11:23:10

标签: backbone.js

我想在我的骨干模型的父级上设置一个属性。

MN.BaseModel = Backbone.Model.extend ({

   iWantToSetThisVar : false,    

   initialize : function(){

   },

   parse: function(response) {
      console.log(this.iWantToSetThisVar); //should now be true
   }

 }); 

不是我用

扩展上面的模型
 MN.Contact = MN.BaseModel.extend({

      initialize : function(){
          this.iWantToSetThisVar = true; 
       },

 }); 

现在,当在MN.Contact上调用parse时,它从BaseModel调用解析函数。但是,“iWantToSetThisVar”在baseModel上没有变为true

0 个答案:

没有答案
相关问题