From 3e1c254ff681871ef4d3449e4340942ce23b86fb Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Tue, 14 Jan 2020 09:15:47 -0800 Subject: [PATCH] acceptWidgets better doc * fixed doc and updated two.html with actual example * fix for #1113 --- demo/two.html | 2 +- doc/README.md | 6 ++++-- src/gridstack.d.ts | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/demo/two.html b/demo/two.html index 6f4aaff97..a68c035cd 100644 --- a/demo/two.html +++ b/demo/two.html @@ -103,7 +103,7 @@

Two grids demo

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, { diff --git a/doc/README.md b/doc/README.md index 6e0737fa1..4b99f6094 100644 --- a/doc/README.md +++ b/doc/README.md @@ -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`) diff --git a/src/gridstack.d.ts b/src/gridstack.d.ts index 5f8fca3a2..bbeeb24d0 100644 --- a/src/gridstack.d.ts +++ b/src/gridstack.d.ts @@ -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)