0
有點怪怪的,我有代碼這兩個部分在兩個文件中,base.js和filter.js: //定義通用對象類的Backbone.js的,爲什麼不能用父get方法
var baseObject = Backbone.Model.extend({
copy: function(){
_clipBoard=this;
},
fetch: function(){
var obj =this;
var criteriaString = encodeURI(JSON.stringify({_id:this.get("_id")}));
var getUrl = _rootUrl+'/nalab/'+this.getMongoType()+'/';
$.getJSON(getUrl + "_find", 'criteria=' + criteriaString, function(data){
var results = data.results;
obj.set(results[0]);
});
}
});
//definition of a baseObject subclass called filter with speical methods
var Filter = baseObject.extend({
getTitleField : function(){
return 'title';
},
getMongoType: function(){
return 'filter';
}
});
那我在Firefox 5以下代碼:
var filter = new Filter({_id:{$oid:"4e43ca017c36ec707b755659"}});
filter.fetch();
console.log(filter);
/*
Firebug shows an object with "attributes" that contains a field 'title'='Filtres avances'
*/
console.log(filter.get('title');
/*
Firebug says undefined
*/
那麼,爲什麼「超級」 GET方法不適用於過濾器類的工作雖然它適用於baseObject類,從來沒有overrid呢?