-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi, thanks for the awesome work on gridstack.js!
I have a feature request regarding GridStack.setupDragIn().
Currently, setupDragIn allows external elements to be dragged into the grid, and automatically attaches the corresponding GridStackWidget data.
However, there is no easy way to hook into the moment after the external element has been successfully dropped and added to the grid.
Proposal:
Add an optional callback function parameter to setupDragIn, like:
GridStack.setupDragIn(
dragIn?: string | HTMLElement[],
dragInOptions?: DDDragOpt,
widgets?: GridStackWidget[],
root: HTMLElement | Document = document,
onDrop?: (newWidget: GridStackWidget, el: HTMLElement) => void
)This callback would be triggered after a new widget is added to the grid, passing the created GridStackWidget and its associated DOM element.
Use case:
- Customize the new widget (e.g., assign unique IDs, initialize additional content, etc.)
- Log user actions or update external state after an item is dropped
Current workaround:
I can listen to the grid's added event and filter by element, but it would be cleaner and more efficient to have a dedicated callback inside setupDragIn.
Thanks again!
Would love to hear your thoughts on this!