UPDATE: I added {{else}} to the nested each and it really seems the template does not iterate over individual spots. It was foolish to think that the log helper would not fire up in such situations. Ill try to dig deeper.
UPDATE2 Thanks for the first answer. Probably not counting from 0 on array indexes makes forEach function to behave funny. 1-st level of each works just fine, 2nd not at all. I will try to change my script so I store X Y coordinates differently. Even though this was convienient.
So I generated a simple array in my IndexController
grid: function(){
//Lets generate a 2-dimensional grid
var data = [];
var limits = this.get('limits');
// console.log(limits);
for(var y = limits.min.y; y <= limits.max.y; y++){
data[y] = new Array(this.get('numberOfColumns'));
for(var x = limits.min.x; x <= limits.max.x; x++){
data[y][x] = 0;
}
}
console.log(data);
// this.get('spots').forEach(function(spot){
// console.log('Y '+spot._data.y+' X '+spot._data.x);
// data[spot._data.y][spot._data.x] = spot._data;
// console.log(spot);
// });
return data;
}.property('limits','numberOfColumns')
Problem is, when I try to iterate over this array in my template I get a lot of undefined values and the html content does not render at all.
{{#each gridrow in grid}}
<div class="gridRow {{unbound is-even _view.contentIndex}}">
{{#each spot in gridrow}}
{{!-- {{log spot}} --}}
{{!-- {{spot-unit class='inline-block'}} --}}
{{log "test"}}
<div class="spot"></div>
{{/each}}
</div>
{{/each}}
"Test" gets logged 800 times, although it should get logged about 50 times. No div.spot gets rendered. I guess its because of some ember meta data which get appended to the array.
I went through quite a lot of API and guides and couldnt find where should I generate such arrays. Should it be in the form of Fixtures? That doesnt seem right. Should it be simple model (therefore no ember data)? Then I would deal with multiple models situation which I would like to avoid if possible. If I generated this array on the server side with data already merged to it, things would be much simpler in the end, but before I go this way, I would really like to know where to properly generate such things on client side.
More info on what I am trying to achieve: I need to generate simple grid on client side consisting of empty tiles which I afterwards fill out with server data. Some of them will remain empty, thats why I cant count on server data alone, some tiles would be missing and grid would be broken.