I m 试图将JSON(从Candards s json_encode)装入Abone JS藏书。 我将问题简化为:
var myJSON = [{ "id":"1","name":"some name","description":"hmmm"}] ;
var myCollection = new MyCollection(myJSON, { view: this });
而且:
MyObject = Backbone.Model.extend({
id: null,
name: null,
description: null
});
MyCollection = Backbone.Collection.extend({
model: MyObject,
initialize: function (models,options) { }
});
错误:
Uncaught Type错误:Cannot use in operator to search for id in
类似问题: Backbone: fetch Collection from服务器
我的“智者”当然似乎以适当的形式出现,我是否失踪了明显的东西? 我曾尝试用简单称道:“1”而不是“id”,结果相同。