Merging data [best practise?]


#1

So I am starting to learn Ember and I am transforming my older JQuery project to this framework. I managed to do a lot of things the “ember-way” but Im scratching my head about one issue at the moment.

In my pure jquery application I had an empty html grid consisting of “tiles” with XY coordinates. I generated this grid based on a few parameters like CenterOfView, numberOfRows, numberOfColumns. Then I did ajax request to a server and filled the tiles with data. There was no data for some tiles and they just remained empty.

When converting this into Ember, I now have 2 issues:

  1. I fail to find a convenient way to create an empty grid. I couldnt find a way to do simple for or while loop in Handlebars. There is forEach of course but for that I would have to create some array which wouldnt be used otherwise.

  2. If I decided that I would create some JSON that would then generate basic info for all tiles (even the empty ones) I would have to then merge it somehow with the server data model. I would end up with two models with duplicate properties.

I believe I will be able to solve my issues when I dig deeper into the framework, but still any insights for this would be of great help to me. Pointing me in the right direction would speed up my progress :blush: