0

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}}
Ravi MCA
  • 2,491
  • 4
  • 20
  • 30
Jerome
  • 1,162
  • 2
  • 16
  • 32

1 Answers1

1

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

Community
  • 1
  • 1
Ravi MCA
  • 2,491
  • 4
  • 20
  • 30
  • Yes for sure in Javascript it's pretty easy but I try to perform that in the HTML each loop of Meteor. I got an idea with your answer I'll try something and give you a feedback – Jerome Jan 30 '17 at 10:03
  • So no my idea didn't work, (it was to add every X millisecond values inside the array who is the one where the each works) but I can't. So your answer is not the right one but thank you for the help – Jerome Jan 30 '17 at 10:13