당신이 당신의 견해에서 모델을 보지 못하는 가장 큰 이유는 렌더가 비동기 전에 일어나기 전에 발생하기 때문입니다. fetch
완료되었습니다.
아래와 같은 것은 더 잘 작동합니다.
mdm.LinksView = Backbone.View.extend({
el: '#link_list',
initialize: function() {
this.collection = new mdm.Posts();
this.listenTo(this.collection, 'reset', this.render);
this.collection.fetch({reset: true});
}
위의 코드는 청취자를 설정합니다 reset
이벤트 collection
그리고 render
그런 일이 발생하면 기능합니다.
또한 지나갈 수 있습니다 success
그리고 error
핸들러가 fetch
렌더링 기능을 수동으로 호출하십시오.
this.collection.fetch({
success: _.bind(function() {
this.render(); }, this)
});
도움이 되었기를 바랍니다!