简体   繁体   中英

How to delay each iteration of a each loop inside a {{#each}} with Meteor?

I'm looping over each values of an array to create Highcharts graphs on the client webpage. The problem is that it lags a bit because it do the each iteration a little too fast.

So my idea is to do something like this:

 {{#each containersToCreateChart}}  
 some html that I need to do for each one  
 then wait X milliseconds
 and do the next iteration
 {{/each}}

Not sure about meteor . But if I want to achieve what you are trying to do in Javascript I will do like this.

 for (i = 0; i < 5; i++) { (function(i) { setTimeout(function() { console.log('delayed by 2 seconds, now value of "i" is:' + i); }, 2000); })(i); } 

for more you can refer here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM