내 collection.fetch가 작동하지 않고 렌더링 할 모델을 얻지 못합니다. 내가 그것을 불을 지르고를 사용하여 디버깅 할 때백본에서 fetch collection.fetch에 대한 모델이 없습니다.
initialize: function(){
ItemCollection.bind("reset", this.render);
},
render: function(){
var data = {
items: itemcollection.models
}
var compiledTemplate = _.template(ItemListTemplate , data);
$("#itemContainer").html(compiledTemplate);
},
재미있는 것은이 제대로 렌더링 : 나는
define([
'underscore',
'backbone',
'model/item_model'
],function(_, Backbone, Item){
var ItemCollection = Backbone.Collection.extend({
model: Item,
url: 'http://posbeta.interprisesolutions.com/POSMobileConnector/Product/loaditembycategory/Event Materials',
parse: function(response) {
return response.Items;
}
});
return ItemCollection;
});
내보기 내 router.js에
itemcollection = new ItemCollection();
itemcollection.fetch();
ItemListView.render();
CartListView.render();
}
내 itemcollection.js
을이이 중단 점을 제거하면 아무 것도 표시되지 않습니다. 어떤 아이디어?
나는 리셋을했지만 작동하지 않습니다. ItemCollection.bind ("reset", this.render); – jongbanaag
당신은'this'를 바인딩해야 할 수도 있습니다 :'ItemCollection.on ('reset', this.render, this); ' – stusmith
나는 명확한 설명을 원합니다. 항목 목록보기에 이미 ItemCollection을 인스턴스화 한 경우 다른보기에서 사용하려면 다시 인스턴스화해야합니까? – jongbanaag