0
다음과 같이 백본 마리오 네트 합성보기가 있습니다.marionette compositeview onfetch
이것은 초기화 방법입니다.
initialize: function(options) {
log.debug("Initialize");
this.wizard = options.wizard;
this.model = new Feed({
id: options.modelid
});
this.modelid = options.modelid;
this.collection = new Similar();
this.listenTo(this.model, "change", this.onFetch);
this.listenTo(this.model, "reset", this.onFetch);
this.collection.fetch({ data: { id: this.modelid }});
this.model.fetch();
},
는 이는 본 onFetch 방법
onFetch: function() {
log.debug("Fetch");
this.$el.html(this.template(this.model.toJSON()));}
이며 이는
appendHtml: function(collectionView, itemView, index) {
log.debug("appendHtml");
var jsonFeed = itemView.model.toJSON();
if (this.prevFeed === null || jsonFeed.start !== this.prevFeed.start) {
var date = new Date(jsonFeed.start);
collectionView.$(this.itemViewContainer).append('<div class="day-divider c-color box-center" ><h3>' + moment(date).format('DD MMMM') + '</h3></div>');
}
collectionView.$(this.itemViewContainer).append(itemView.el);
this.prevFeed = jsonFeed;
},
내 컬렉션이 HTML 콘텐츠를 덮어 쓰는 onFetch 함수 비운의 append 방법이다. 이것은 내 기록입니다.
DEBUG - Initialize
DEBUG - Render
DEBUG - appendHtml
DEBUG - appendHtml
DEBUG - appendHtml
DEBUG - Render
DEBUG - Fetch
어떤 생각입니까? 어떻게 해결할 수 있습니까?
몇 가지 생각을 한 후에 나는이 방법을이 결론에 도달했다. $ el.html (this.model.toJSON())); }는 render 메소드에 있어야합니다 (백본 메소드를 대체). –