Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acceptWidgets option does not work when setting grid stack item droppable #948

Closed
ghost opened this issue Oct 18, 2018 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 18, 2018

First of all, thanks for the great library!

Subject of issue

I want to drop an external element into a droppable grid stack item but i can not do that because gridstack also accept that element and move other grid stack items to make room for the new widget

Your environment

  • version of gridstack.js: 0.4.0
  • which browser and its version: Google Chrome 69.0.3497.100

Steps to reproduce

Initialize gridstack with options acceptWidgets: '.grid-stack-item'
Create a side bar contain items which have class .side-bar-item
Using jQueryUI to make grid stack items droppable, which accept .side-bar-item as draggable element
Drag a side bar item into a grid stack item

Here is demo.

Expected behaviour

Grid should not accept side bar item

Actual behaviour

grid stack items are moved down to make room for new widget so that I can not drop side bar item into the grid stack item

Setting acceptWidgets: false fixed the issue, but I also want to add new widget from outside by dragging it into the grid.

I think this issue is because drop event does not stop propagation, so everytime i drag an element into grid stack item, the event also move up to parent grid container and causing the grid to handle this element

I tried to fix the issue by using greedy option and calling stopPropagation() from drop event, but it does not work.

@ghost ghost changed the title acceptWidgets option does not work acceptWidgets option does not work when setting grid stack item droppable Oct 18, 2018
@adumesny
Copy link
Member

@ghost are you asking about creating a nested grid (drop inside) rather than move over the other ?
if so #1009 might be a dup.

@adumesny
Copy link
Member

if you are tying to drop the green box only inside the red boxes (assuming they are nested grids), you can do that with latest 0.6.4 code - see example https://gridstackjs.com/demo/nested.html
Your test code overrides the grip droppable to accept the green item...

if you are trying to created nested grids on the fly, but still able to add to the top grid a well, then it's a dup of #1009.

closing this, please re-open if I misunderstood and you can show a simpler example with latest code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant