Every nth row in handlebars shows weird behaviour

痴心易碎 提交于 2020-01-03 02:49:08

问题


 {{#each orderData}}
{{#everyOther @key 4 }}
<div class="row">
    {{/everyOther}}

    <div class="col-md-3">
        <a class="aremove" href="/Channel/Details/{{getValueAtIndex ../channelIds @key}}" data-bypass>
        <div class="thumbnail">
            <img src="{{getImageSourceChannel ../channelNames @key name}}" class="">
            <div class="caption">
             <p><b>{{getObjectAtIndex ../channelNames @key}}</b></p>
             <p class="">{{this.slices.3.count}} new orders</p>
             <p class="">{{this.slices.0.count}} back orders</p>                   

         </div>
     </div>
 </a>
 </div>
 {{#everyOther @key 4 }}
</div>
 {{/everyOther}}

{{/each}}

Helper:

    Handlebars.registerHelper("everyOther", function (index, amount, scope) {
    if ( ++index % amount ) 
        return scope.inverse(this);
    else 
        return scope.fn(this);
});

I am printing 4 elements at a time. What happens is really weird out here the new orders data keeps changing from one column to another.

I don't understand why is it happening. When i refresh the page 4 times the behaviour shows up.

Please find below what happens:

1

2

来源:https://stackoverflow.com/questions/31907566/every-nth-row-in-handlebars-shows-weird-behaviour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!