diff --git a/README.md b/README.md index 0d0a236..f4d979e 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,7 @@ Changes #### v0.2.2 (current development version) +- fix grid initialization - add `cell_height`/`cell_width` API methods - fix boolean attributes (issue #31) diff --git a/src/gridstack.js b/src/gridstack.js index 5783e88..9ff5044 100644 --- a/src/gridstack.js +++ b/src/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); }); }