I have implemented a marionette region that draws columns depending on the screen size, so i have variable number of columns. The problem that i have is that i want to locate the itemView in the column with the smallest height. But the CompositeView appendHtml method seems to append all itemViews before a i can calculate correctly the height of the column. The ItemView has a image and is not rendered yet,so im not calculating correctly the height.
I paste my aproximation:
appendHtml: (collectionView, itemView, index) ->
$("#column-container").waitForImages ->
smallest_column = 0
columns= $("#column-container").children().length
column_sizes = []
for i in [0...columns]
column_sizes[i] = $($("#column-container").children()[i]).height()
smallest_column = column_sizes.indexOf(Math.min.apply(Math,column_sizes))
target = $($("#column-container").children()[smallest_column])
target.append(itemView.el)
I have watched that this method appends all the collection items and this could be one reason to do this logic in other place.
PD: I dont want to use masonry.