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

Skip to content

Commit 716db1c

Browse files
committed
fix undefined options
1 parent 2088a21 commit 716db1c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/gridstack.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
});
367367
});
368368
_.chain(elements).sortBy(function (x) { return x.i; }).each(function (i) {
369-
self._prepare_element(i.el);
369+
self._prepare_element(i.el, this.opts);
370370
});
371371
}
372372

@@ -376,18 +376,18 @@
376376
this.container.append(this.placeholder);
377377
this.container.height((this.grid.get_grid_height()) * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin);
378378

379-
var on_resize_handler = function () {
379+
var on_resize_handler = function (opts) {
380380
if (self._is_one_column_mode()) {
381381
if (one_column_mode)
382382
return;
383383

384384
one_column_mode = true;
385385

386386
_.each(self.grid.nodes, function (node) {
387-
if (!node.no_move && this.opts.draggable !== false) {
387+
if (!node.no_move && opts.draggable !== false) {
388388
node.el.draggable('disable');
389389
}
390-
if (!node.no_resize && this.opts.resizable !== false) {
390+
if (!node.no_resize && opts.resizable !== false) {
391391
node.el.resizable('disable');
392392
}
393393
});
@@ -399,18 +399,18 @@
399399
one_column_mode = false;
400400

401401
_.each(self.grid.nodes, function (node) {
402-
if (!node.no_move && this.opts.draggable !== false) {
402+
if (!node.no_move && opts.draggable !== false) {
403403
node.el.draggable('enable');
404404
}
405-
if (!node.no_resize && this.opts.resizable !== false) {
405+
if (!node.no_resize && opts.resizable !== false) {
406406
node.el.resizable('enable');
407407
}
408408
});
409409
}
410410
};
411411

412-
$(window).resize(on_resize_handler);
413-
on_resize_handler();
412+
$(window).resize(on_resize_handler(this.opts));
413+
on_resize_handler(this.opts);
414414
};
415415

416416
GridStack.prototype._update_styles = function (max_height) {
@@ -443,7 +443,7 @@
443443
return $(window).width() <= this.opts.min_width;
444444
};
445445

446-
GridStack.prototype._prepare_element = function (el) {
446+
GridStack.prototype._prepare_element = function (el, opts) {
447447
var self = this;
448448
el = $(el);
449449

@@ -577,7 +577,7 @@
577577
if (typeof options.max_height !== 'undefined') el.attr('data-gs-max-height', options.max_height);
578578
if (typeof auto_position !== 'undefined') el.attr('data-gs-auto-position', options.auto_position ? 'yes' : null);
579579
this.container.append(el);
580-
this._prepare_element(el);
580+
this._prepare_element(el, options);
581581
this._update_container_height();
582582
};
583583

0 commit comments

Comments
 (0)