js 파일;백본 컬렉션을 표시합니다 (컬렉션 모음은 아마도?)
var dataModel = Backbone.Model.extend({
defaults : {
dataID : 'unknown',
text : 'unknown'
}
});
var LinkCollection = Backbone.Collection.extend({
model : dataModel
});
은 컬렉션 크기가 8이라고 할 수 있습니다. 한 번에 3 개씩 표시하고 싶습니다. 스크립트의 구조로 인해 컬렉션 항목을 별도 div로 나누어야합니다.
html 파일;
<div class="item">
<div class="carousel-subItem"> <-- Collection item #1
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
<div class="carousel-subItem"> <-- Collection item #2
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
<div class="carousel-subItem"> <-- Collection item #3
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
</div>
<div class="item">
<div class="carousel-subItem"> <-- Collection item #4
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
<div class="carousel-subItem"> <-- Collection item #5
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
<div class="carousel-subItem"> <-- Collection item #6
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
</div>
<div class="item">
<div class="carousel-subItem"> <-- Collection item #7
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
<div class="carousel-subItem"> <-- Collection item #8
<span>{{dataID}}</span> <br /> <span>{{text}}</span>
</div>
</div>
이 html 구조를 동적으로 생성하는 데 어려움을 겪고 있습니다. 컬렉션의 크기 캔이 다양하기 때문에 (... 구조는 완전히 동적 등되어야한다
{{#each dataModel}}
// code goes here, to create the above structure..
{{/each}}
왜 로직을 렌더링으로 이동하지 않습니까? – chchrist
무엇의 렌더링? – bentrm
Backbone'render' 메쏘드는 OP와 같이 Handlebars 템플릿에서 작동 할 수 있습니다. –