뷰에 전달 된 컬렉션을 참조하고 사용하는 방법을 이해하려고합니다. 컬렉션에 대한 참조가없는 것 같지만 모델이 사용되고 있습니다. 또한 내 API에 바인딩 된 컬렉션을 사용할 때 컬렉션 항목을 바인딩하거나 표시 할 수 없지만 하드 코딩 된 컬렉션을 사용할 때는 작동합니다. 어느 시점에서 내 컬렉션을 가져와야하나요? 제 컬렉션이 좋고 경로가 좋습니다. 나는 내 애플 리케이션 내내 아무런 문제없이 그것을 사용합니다. - (가) 컬렉션 통과 않습니다 참조받을백본 목록 컬렉션에 바인딩
module.exports = Backbone.Collection.extend({
model: Employee,
url:"api/employees"
});
MAINVIEW
module.exports = base.extend({
el: '#content',
template:template,
initialize: function() {
// var items = new EmployeeCollection([
// {id: 1, firstName: "Test1 fName", lastName: "Test1 lName"},
// {id: 2, firstName: "Test2 fName", lastName: "Test2 lName"},
// {id: 3, firstName: "Test3 fName", lastName: "Test3 lName"}
// ]);
EmployeeListCollection = new EmployeeCollection();
//this.itemView = new EmployeeListView({collection: items}); //this syntax works if I uncomment the code above to create my item list
this.itemView = new EmployeeListView({collection: EmployeeListCollection}); //do i need to fetch the collection at some point?
this.render();
},
render: function(){
this.el.innerHTML = Mustache.to_html(this.template);
this.itemView.render();
$("#empList").html(this.itemView.el);
}
});
ItemListView : 아래
코드인가? 모델 참조가 보이지만 컬렉션을 전달했습니다.
자신의 대답조차도 [수용 가능] (http://stackoverflow.com/help/accepted-answer)이 아닙니다. – pnuts