You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
see [jsfiddle sample](https://jsfiddle.net/adumesny/jqhkry7g) as running example too.
@@ -276,24 +297,24 @@ GridStack.init(options);
276
297
If you're still experiencing issues on touch devices please check [#444](https://github.com/gridstack/gridstack.js/issues/444)
277
298
278
299
279
-
## Migrating to v0.6.x
300
+
## Migrating to v0.6
280
301
281
302
starting in 0.6.x `change` event are no longer sent (for pretty much most nodes!) when an item is just added/deleted unless it also changes other nodes (was incorrect and causing inefficiencies). You may need to track `added|removed`[events](https://github.com/gridstack/gridstack.js/tree/develop/doc#events) if you didn't and relied on the old broken behavior.
282
303
283
-
## Migrating to v1.0.0
304
+
## Migrating to v1
284
305
285
306
v1.0.0 removed Jquery from the API and external dependencies, which will require some code changes. Here is a list of the changes:
286
307
287
-
1. see [Migrating to v0.6.x](#migrating-to-v06x) if you didn't already
308
+
1. see [Migrating to v0.6](#migrating-to-v06) if you didn't already
288
309
289
-
2. your code only needs to include `gridstack.all.js` and `gristack.css` (don't include other JS) and is recommended you do that as internal dependencies will change over time. If you are jquery based, also see note below.
310
+
2. your code only needs to include `gridstack.all.js` and `gristack.css` (don't include other JS) and is recommended you do that as internal dependencies will change over time. If you are jquery based, see [jquery app](#jquery-application) below.
290
311
291
312
3. code change:
292
313
293
314
**OLD** initializing code + adding a widget + adding an event:
294
315
```js
295
316
// initialization returned Jquery element, requiring second call to get GridStack var
296
-
let grid =$('.grid-stack').gridstack(opts?).data('gridstack');
317
+
var grid =$('.grid-stack').gridstack(opts?).data('gridstack');
297
318
298
319
// returned Jquery element
299
320
grid.addWidget($('<div><div class="grid-stack-item-content"> test </div></div>'), undefined, undefined, 2, undefined, true);
@@ -302,13 +323,13 @@ grid.addWidget($('<div><div class="grid-stack-item-content"> test </div></div>')
302
323
$('.grid-stack').on('added', function(e, items) {/* items contains info */});
303
324
304
325
// grid access after init
305
-
let grid =$('.grid-stack').data('gridstack');
326
+
var grid =$('.grid-stack').data('gridstack');
306
327
```
307
328
**NEW**
308
329
```js
309
330
// element identifier defaults to '.grid-stack', returns the grid
310
-
// Note: for Typescript use window.GridStack.init() until next native TS version
311
-
let grid =GridStack.init(opts?, element?);
331
+
// Note: for Typescript use window.GridStack.init() until next native 2.x TS version
332
+
var grid =GridStack.init(opts?, element?);
312
333
313
334
// returns DOM element
314
335
grid.addWidget('<div><div class="grid-stack-item-content"> test </div></div>', {width:2});
@@ -317,9 +338,9 @@ grid.addWidget('<div><div class="grid-stack-item-content"> test </div></div>', {
317
338
grid.on('added', function(e, items) {/* items contains info */});
318
339
319
340
// grid access after init
320
-
let grid =el.gridstack; // where el = document.querySelector('.grid-stack') or other ways...
341
+
var grid =el.gridstack; // where el = document.querySelector('.grid-stack') or other ways...
@@ -332,22 +353,23 @@ Recommend looking at the [many samples](./demo) for more code examples.
332
353
333
354
### jQuery Application
334
355
335
-
We're working on implementing HTML5 drag'n'drop through the plugin system. Right now it is still jquery-ui based. Because of that we are still bundling `jquery` (3.5.1) + `jquery-ui` (1.12.1 minimal drag|drop|resize) internally in `gridstack.all.js`. IFF your app needs to bring your own version instead, you should **instead** include `gridstack-poly.min.js` (optional IE support) + `gridstack.min.js` + `gridstack.jQueryUI.min.js` after you import your JQ libs. But note that there are issue with jQuery and ES6 import (see [1306](https://github.com/gridstack/gridstack.js/issues/1306))
356
+
We're working on implementing HTML5 drag'n'drop through the plugin system. Right now it is still jquery-ui based. Because of that we are still bundling `jquery` (3.5.1) + `jquery-ui` (1.12.1 minimal drag|drop|resize) internally in `gridstack.all.js`. IFF your app needs to bring your own version instead, you should **instead** include `gridstack-poly.min.js` (optional IE support) + `gridstack.min.js` + `gridstack.jQueryUI.min.js` after you import your JQ libs. But note that there are issue with jQuery and ES6 import (see [1306](https://github.com/gridstack/gridstack.js/issues/1306)).
357
+
358
+
Note: v2.0.-rc does not currently support importing GridStack Drag&Drop without also including our jquery + jqueryui. Still trying to figure how to make that bundle possible.
336
359
337
-
## Migrating to v2.0.0
360
+
## Migrating to v2
338
361
339
-
make sure to read v1.0.0 migration first!
362
+
make sure to read v1 migration first!
340
363
341
-
v2.x is a Typescript rewrite of 1.x, removing all jquery events, using classes and overall code cleanup. Your code might need to change from 1.x
364
+
v2.x is a Typescript rewrite of 1.x, removing all jquery events, using classes and overall code cleanup to support ES6 modules. Your code might need to change from 1.x
342
365
343
-
1. In general methods that used no args (getter) vs setter are not used in Typescript when the arguments differ.
344
-
Also legacy methods that used to take many parameters will now take a single object (typically `GridstackOptions` or `GridStackWidget`).
366
+
1. In general methods that used no args (getter) vs setter can't be used in TS when the arguments differ (set/get are also not function calls so API would have changed). Instead we decided to have <b>all set methods return</b> `GridStack` to they can be chain-able (ex: `grid.float(true).cellHeight(10).column(6)`). Also legacy methods that used to take many parameters will now take a single object (typically `GridstackOptions` or `GridStackWidget`).
345
367
346
368
```
347
-
removed `addWidget(el, x, y, width, ...)`-->use the widget options version instead `addWidget(el, {with, ...})`
369
+
`addWidget(el, x, y, width, height)`-->`addWidget(el, {with: 2})`
348
370
`float()` to get value -->`getFloat()`
349
371
'cellHeight()` to get value --> `getCellHeight()`
350
-
'verticalMargin' is now 'margin' grid options and applies to all 4 sides.
372
+
'verticalMargin' is now 'margin' grid options and API that applies to all 4 sides.
- add `save()` and `load()` to serialize grids from JSON, saving all attributes (not just w,h,x,y) [1286](https://github.com/gridstack/gridstack.js/issues/1286)
let$el: JQuery=$(elasany);// workaround Type 'string' is not assignable to type 'PlainObject<any>' - see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/29312
71
72
$el.draggable(opts);
72
73
returnthis;
73
74
}
@@ -89,7 +90,7 @@ export class GridStackDDJQueryUI extends GridStackDD {
89
90
}
90
91
91
92
publicisDraggable(el: GridStackElement): boolean{
92
-
let$el: JQuery=$(el);
93
+
let$el: JQuery=$(elasany);// workaround Type 'string' is not assignable to type 'PlainObject<any>' - see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/29312
0 commit comments