インスタンスが2つあります。 OS Win7のローカル、OS LinuxのServerインスタンスBackbone.jsサーバインスタンス内の子インスタンスではなく、ローカルインスタンス内の子オブジェクトを返すfetch()
JSONデータをフェッチして、次のコードを使用してモデルに設定しています。
var RModel = Backbone.Model.extend({
idAttribute: 'name',
parse: function (response) {
return {
'name': response.name,
'title': response.title,
'description': response.description,
'parameters': new ParamsList(response.parameters)
};
}
});
that.model = new RModel();
that.model.url = "url/" + '?limited=false';
that.model.fetch({
cache: false
}).done(function() {
that.headerTemplate = that.headerTemplateEdit;
that.bodyTemplate = that.bodyTemplateEdit;
that.footerTemplate = footerTemplate;
that.load({});
});
私のローカルインスタンスでは、次のコードの結果がコンソールに表示されます。
this.model
child
_changing:false
_pending:false
_previousAttributes:Object
attributes:Object
changed:Object
cid:"c217"
id:"testUndefinedParam"
url:"/url?limited=false"
__proto__:
Backbone.Model
サーバインスタンスで
this.model
i
_changing: false
_pending: false
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c25920"
id: "testDateError2"
url: "/url?limited=false"
__proto__: t.Model
誰もがこの問題に出くわした場合はいくつかの方法が適切にJSONデータを取得し表示してください。
データを取得する際にどのような問題がありますか?データはモデルの属性内にあります。 –