私はJavaScript配列を持っています:
var personDetails = [
{firstName: "Anup", lastName: "Vasudeva", City: "Delhi"},
{firstName: "Vikas", lastName: "Kumar", City: "Banglore"},
{firstName: "Dannis", lastName: "Richie", City: "Texas"},
{firstName: "Ajay", lastName: "Sharma", City: "Pune"},
{firstName: "Deepak", lastName: "Aggarwal", City: "Delhi"},
{firstName: "Ajay", lastName: "Sharma", City: "Banglore"}
]
これが私がデザインしようとしているテンプレートです:
<div class="left">
<!-- Should display the first half of the rows -->
{{tmpl($data) "#someTemplate"}}
</div>
<div class="right">
<!-- Should display the rest half of the rows -->
{{tmpl($data) "#personTemplate"}}
</div>
<script id="personTemplate" type="text/x-jquery-tmpl">
{{each personDetails}}
<div class="person">
<div>${firstName}</div>
<div>${lastName}</div>
<div>${city}</div>
</div>
{{/each}}
行の前半を含み、行の後半を含むように配列を操作するにはどうすればよいですか。
編集:実際には、ユーザーは配列をそのまま渡し、配列を2つの等しい半分にスライスするのはテンプレートロジックです。
読んでくれてありがとう。