ractivejs - How to loop in ractive.js -
i have got following data (sample):
"data": { "eventsheading": "upcoming events", "eventstobedisplayed": 3, "alleventlinktext": "see events", "eventslist": [ { "eventdate": "22/12/2015", "eventtitle": "event info 1" }, { "eventdate": "22/12/2015", "eventtitle": "event info 2" }, { "eventdate": "14/01/2016", "eventtitle": "event info 3" }, { "eventdate": "14/01/2016", "eventtitle": "event info 4" } ] }
and have this:
{{#eventslist}} <tr> <td class="date-column">{{eventdate}}</td> <td class="text-link truncate-text"><span decorator="tooltip:{{eventtitle}}" tabindex="0">{{eventtitle}}</span> </tr> {{/}}
and print data eventlist
. want add for
loop
i=0;i<={{eventstobedisplayed}};i++
so 3 of data show.
what think best approach this?
you can add indexer loop , conditionally filter inside loop:
{{#eventslist:i}} {{# < eventstodisplay}} <tr> <td class="date-column">{{eventdate}}</td> <td class="text-link truncate-text"><span decorator="tooltip:{{eventtitle}}" tabindex="0">{{eventtitle}}</span> </tr> {{/}} {{/}}
Comments
Post a Comment