Skip to content

Commit b066ba7

Browse files
authored
Merge pull request #2029 from adumesny/master
acceptWidgets doc tweaks
2 parents ecd4c83 + 3831d9a commit b066ba7

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

doc/README.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,10 @@ gridstack.js API
6666

6767
## Grid Options
6868

69-
- `acceptWidgets` - Accept widgets dragged from other Gridstack grids or from outside (default: `false`). Can be:
70-
* `true` (The Gridstack grid accepts HTML elements (A Gridstack Grid item is also a HTML element) having `'.grid-stack-item'` as class attribute) or `false`
71-
* Class name. For example, if `acceptWidgets` is set to `'.red-grid-items'`, then the Gridstack grid will only accept HTML elements having `.red-grid-items` as class attribute.
72-
* `function (i: number, element: Element): boolean`. This callback function which is assigned to `acceptWidgets` will be invoked when the user drags an HTML element (A Gridstack Grid item is also a HTML element) on to the Gridstack Grid. For example if `acceptWidgets` is set to
73-
74-
```js
75-
(el) => { const subgridElement = el.getElementsByClassName("grid-stack")
76-
if (subgridElement && subgridElement.length) {
77-
return false;
78-
} else {
79-
return true;
80-
}
81-
}
82-
```
83-
84-
This call back function will be invoked as soon as the user drags an HTML element onto the Gridstack grid, the function parameter `el` will contain the HTML element which was dragged onto the Gridstack Grid. The callback function written above prevents a Gridstack subgrid from being dropped inside of another Gridstack subgrid (Gridstack Grids have class attribute of `.grid-stack`, the callback function in this case makes sure that the HTML element entering the grid doesn't contain any Gridstack grids). See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
69+
- `acceptWidgets` - Accept widgets dragged from other grids or from outside (default: `false`). Can be:
70+
* `true` will accept HTML element having `'.grid-stack-item'` as class attribute, else `false`
71+
* string for explicit class name to accept instead
72+
* `function (el: Element): boolean` function called before an item will be accepted when entering a grid. the function will be passed the item being dragged, and should return true | false. See [example](https://github.com/gridstack/gridstack.js/blob/master/demo/two.html#L62)
8573
- `alwaysShowResizeHandle` - possible values (default: `mobile`) - does not apply to non-resizable widgets
8674
* `false` the resizing handles are only shown while hovering over a widget
8775
* `true` the resizing handles are always shown

0 commit comments

Comments
 (0)