Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16884fd

Browse files
committed
fix grid initialization
1 parent 1ed2171 commit 16884fd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ Changes
310310

311311
#### v0.2.2 (current development version)
312312

313+
- fix grid initialization
313314
- add `cell_height`/`cell_width` API methods
314315
- fix boolean attributes (issue #31)
315316

src/gridstack.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,16 @@
352352
}, this.opts.float, this.opts.height);
353353

354354
if (this.opts.auto) {
355+
var elements = [];
355356
this.container.find('.' + this.opts.item_class).each(function (index, el) {
356-
self._prepare_element(el);
357+
el = $(el);
358+
elements.push({
359+
el: el,
360+
i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * parseInt(el.attr('data-gs-width'))
361+
});
362+
});
363+
_.chain(elements).sortBy(function (x) { return x.i; }).each(function (i) {
364+
self._prepare_element(i.el);
357365
});
358366
}
359367

0 commit comments

Comments
 (0)