简体   繁体   English

当拖动到指定的div时如何删除Gridstack.js小部件

[英]How to get Gridstack.js widgets to remove when dragged to specified div

I'm trying to get widgets in a grid to get removed when a widget is dragged into a separate Div, but I can't seem to get it working using 'removable' in the grid's options. 我正在尝试将小部件拖动到单独的Div中时将其放在网格中以将其删除,但是我似乎无法使用网格选项中的“可移动”使其工作。

I've been through the docs ( https://github.com/gridstack/gridstack.js/tree/develop/doc ) and tried different options that are on there as well as tried to replicate one of the demos that has the functionality working ( http://gridstackjs.com/demo/two.html ) I've looked for other people who've had these issues too but can't find any posts that were able to help with this problem. 我浏览过文档( https://github.com/gridstack/gridstack.js/tree/develop/doc ),并尝试了其中的不同选项,并尝试复制具有该功能的演示之一工作( http://gridstackjs.com/demo/two.html )我一直在寻找其他也遇到过这些问题但找不到任何能够解决此问题的帖子的人。

The First Div is where I want to drag the widgets to, and the second is where I'll be dragging them from. 第一个Div是我要将小部件拖到的位置,第二个是我要将它们拖到的位置。

    <div class = 'trash ui-droppable'>
        <h1 class = 'text-center pt-4'><?= FontAwesome::light('trash'); ?> 
    </h1>
    </div>

    <div class = 'grid-stack mt-3 ui-droppable'>
        <!-- Widgets set here -->
    </div>

Here's the JQuery which sets the grid's options, the option that I think should be allowing widgets to be dropped into is removeable and set it to the first Div's class name of ".trash". 这是设置网格选项的JQuery,我认为应该允许将小部件放入其中的选项是可删除的,并将其设置为第一个Div的类名“ .trash”。

    var options = {
        cellHeight: 100,
        verticalMargin: 10,
        removable: '.trash'
    };
    $('.grid-stack').gridstack(options);

What should be happening is I drag a widget over to the top Div, and the widget should be removed from the grid entirely but instead when dragged out and released acts like it's been dragged out the grid and places it back to where it was. 应该发生的是,我将一个小部件拖到顶部的Div上,并且应该将其完全从网格中删除,但是当被拖出并释放时,就像将其拖出网格并将其放回原处一样。

我遇到了同样的问题,此问题已通过为垃圾箱div设置最小高度(例如75px)来解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM