Soy nuevo en Backbone. Así que estoy tratando de obtener datos del servicio REST.Backbone.js + Rest. La colección no se completa después de fetch()
este es mi código simple:
$(function() {
var Entity = Backbone.Model.extend({
url: function() {
return 'http://localhost:8080/rest/entity/'+this.id;
}
});
var EntityList = Backbone.Collection.extend({
model: Entity,
url: 'http://localhost:8080/rest/entity'
});
var entityList = new EntityList();
entityList.fetch();
});
mis devuelve el servicio de descanso junto JSON:
[{"id":1387,
"version":3,
"entityName":"entity01",
"entityLabel":"Entity01",
"entityPluralLabel":"Entity01",
"attributes":
[{"id":1425,
"slot":"D001",
"version":0,
"attributeName":"dfield",
"attributeType":
{"id":7,
"description":"Date",
"attributeType":"date",
"databaseType":"DATE"
},
"options":[],
"order":2,
"attributeLabel":"dField",
"checked":null
},
{"id":1424,
"slot":"S001",
"version":0,
"attributeName":"txfield",
"attributeType":
{"id":1,
"description":"Textbox",
"attributeType":"textbox",
"databaseType":"STRING"
},
"options":[],
"order":1,
"attributeLabel":"txField",
"checked":null
}
]
},
{"id":1426,
"version":3,
"entityName":"entity02",
"entityLabel":"Entity02",
"entityPluralLabel":"Entity02",
"attributes":
[{"id":1464,
"slot":"D001",
"version":0,
"attributeName":"dfield",
"attributeType":
{"id":7,
"description":"Date",
"attributeType":"date",
"databaseType":"DATE"
},
"options":[],
"order":2,
"attributeLabel":"dField",
"checked":null
}
]
}
]
En depurador veo que la petición fue enviada al servicio REST y la respuesta fue recibido, ¿cómo puedo ver si la colección de entityList está poblada con datos recibidos o no? En el depurador, entityList.models está vacío después de entityList.fetch();
¿Estoy en el camino correcto o algo está mal con mi código?
de la columna vertebral se bastante simple. Tal vez sea útil simplemente pasar a través de la fuente real de la red troncal para ver qué está pasando. – Evert