Skip to content

Commit a9c76d5

Browse files
committed
feature(gridster): added auto_init config option, default to true
Useful when using `positionschanged` event, fired before gridster instance is cached.
1 parent 589d7fd commit a9c76d5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/jquery.gridster.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
autogrow_cols: false,
3232
autogenerate_stylesheet: true,
3333
avoid_overlapped_widgets: true,
34+
auto_init: true,
3435
serialize_params: function($w, wgd) {
3536
return {
3637
col: wgd.col,
@@ -89,6 +90,8 @@
8990
* @param {Boolean} [options.avoid_overlapped_widgets] Avoid that widgets loaded
9091
* from the DOM can be overlapped. It is helpful if the positions were
9192
* bad stored in the database or if there was any conflict.
93+
* @param {Boolean} [options.auto_init] Automatically call gridster init
94+
* method or not when the plugin is instantiated.
9295
* @param {Function} [options.serialize_params] Return the data you want
9396
* for each widget in the serialization. Two arguments are passed:
9497
* `$w`: the jQuery wrapped HTMLElement, and `wgd`: the grid
@@ -141,7 +144,7 @@
141144
this.generated_stylesheets = [];
142145
this.$style_tags = $([]);
143146

144-
this.init();
147+
this.options.auto_init && this.init();
145148
}
146149

147150
Gridster.generated_stylesheets = [];

0 commit comments

Comments
 (0)