0
大家好數組,
如何訪問此數組中的骨幹中的每個對象的字段(僱員&位置)?
var DataModel = Backbone.Model.extend({
// urlRoot: "https://corporate-dashboard.firebaseio.com/locations.json"
urlRoot: ""
});
var locationModel = new DataModel();
locationModel.urlRoot = "https://corporate-dashboard.firebaseio.com/locations.json"
locationModel.fetch()
console.log(locationModel.get("Location")); >> Got "undefined"
tried locationModel.get(0) and locationModel[0] >> got "undefined"
謝謝!
運行完美。但是,我如何將它綁定到視圖?謝謝。 –
您可以創建Backbone視圖並傳遞集合:'var view = new MyView({collection:new DataCollection()}); '。在'MyView'中,你聲明'sync'事件,使'fetch'和操作集合顯示在視圖模板中 –