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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -