Skip to content

Commit

Permalink
acceptWidgets better doc
Browse files Browse the repository at this point in the history
* fixed doc and updated two.html with actual example
* fix for #1113
  • Loading branch information
Alain Dumesny committed Jan 14, 2020
1 parent 097c7dd commit 3e1c254
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/two.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h1>Two grids demo</h1>
float: false,
removable: '.trash',
removeTimeout: 100,
acceptWidgets: '.grid-stack-item'
acceptWidgets: function(i, el) { return true; } // function example, else can be simple: true | false | '.someClass' value
};
$('#grid1').gridstack(options);
$('#grid2').gridstack($.extend({}, options, {
Expand Down
6 changes: 4 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ gridstack.js API

## Options

- `acceptWidgets` - if `true` of jquery selector the grid will accept widgets dragged from other grids or from
outside (default: `false`) See [example](http://gridstackjs.com/demo/two.html)
- `acceptWidgets` - accept widgets dragged from other grids or from outside (default: `false`). Can be:
* `true` (uses `'.grid-stack-item'` class filter) or `false`
* string for explicit class name
* function (i: number, element: Element) returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
- `alwaysShowResizeHandle` - if `true` the resizing handles are shown even if the user is not hovering over the widget
(default: `false`)
- `animate` - turns animation on (default: `false`)
Expand Down
8 changes: 5 additions & 3 deletions src/gridstack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,12 @@ declare namespace GridStackUI {
*/
interface GridstackOptions {
/**
* if true of jquery selector the grid will accept widgets dragged from other grids or from
* outside (default: false) See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
* accept widgets dragged from other grids or from outside (default: `false`). Can be:
* `true` (uses `'.grid-stack-item'` class filter) or `false`,
* string for explicit class name,
* function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html)
*/
acceptWidgets ? : boolean | string | ((i: number, element: Element) => boolean | string);
acceptWidgets ? : boolean | string | ((i: number, element: Element) => boolean);

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

0 comments on commit 3e1c254

Please sign in to comment.