From e24192bf8a799c1345e6b44666eddd8d2758a511 Mon Sep 17 00:00:00 2001 From: Pavel Reznikov Date: Fri, 19 Dec 2014 17:35:18 -0800 Subject: [PATCH] update gridstack --- gridstack.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gridstack.js b/gridstack.js index 5783e88..9ff5044 100644 --- a/gridstack.js +++ b/gridstack.js @@ -352,8 +352,16 @@ }, this.opts.float, this.opts.height); if (this.opts.auto) { + var elements = []; this.container.find('.' + this.opts.item_class).each(function (index, el) { - self._prepare_element(el); + el = $(el); + elements.push({ + el: el, + i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * parseInt(el.attr('data-gs-width')) + }); + }); + _.chain(elements).sortBy(function (x) { return x.i; }).each(function (i) { + self._prepare_element(i.el); }); }