Skip to content

Commit 3e1c254

Browse files
author
Alain Dumesny
committed
acceptWidgets better doc
* fixed doc and updated two.html with actual example * fix for #1113
1 parent 097c7dd commit 3e1c254

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

demo/two.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ <h1>Two grids demo</h1>
103103
float: false,
104104
removable: '.trash',
105105
removeTimeout: 100,
106-
acceptWidgets: '.grid-stack-item'
106+
acceptWidgets: function(i, el) { return true; } // function example, else can be simple: true | false | '.someClass' value
107107
};
108108
$('#grid1').gridstack(options);
109109
$('#grid2').gridstack($.extend({}, options, {

doc/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ gridstack.js API
6262

6363
## Options
6464

65-
- `acceptWidgets` - if `true` of jquery selector the grid will accept widgets dragged from other grids or from
66-
outside (default: `false`) See [example](http://gridstackjs.com/demo/two.html)
65+
- `acceptWidgets` - accept widgets dragged from other grids or from outside (default: `false`). Can be:
66+
* `true` (uses `'.grid-stack-item'` class filter) or `false`
67+
* string for explicit class name
68+
* function (i: number, element: Element) returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
6769
- `alwaysShowResizeHandle` - if `true` the resizing handles are shown even if the user is not hovering over the widget
6870
(default: `false`)
6971
- `animate` - turns animation on (default: `false`)

src/gridstack.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,12 @@ declare namespace GridStackUI {
398398
*/
399399
interface GridstackOptions {
400400
/**
401-
* if true of jquery selector the grid will accept widgets dragged from other grids or from
402-
* outside (default: false) See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
401+
* accept widgets dragged from other grids or from outside (default: `false`). Can be:
402+
* `true` (uses `'.grid-stack-item'` class filter) or `false`,
403+
* string for explicit class name,
404+
* function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
403405
*/
404-
acceptWidgets ? : boolean | string | ((i: number, element: Element) => boolean | string);
406+
acceptWidgets ? : boolean | string | ((i: number, element: Element) => boolean);
405407

406408
/**
407409
* if true the resizing handles are shown even if the user is not hovering over the widget (default?: false)

0 commit comments

Comments
 (0)