【问题标题】:How do I remove an element in dragula after cloning?克隆后如何删除dragula中的元素?
【发布时间】:2018-12-06 10:08:19
【问题描述】:

从父容器id=left-copy-1tomany 拖动元素后,我希望从克隆容器id=right-copy-1tomany 中删除一些克隆的元素。我想通过使用 removeOnSpill: true 函数来删除它们,该函数应该让我将元素拖出容器以将其删除。有没有办法使用克隆代码进行这项工作?

HTML

<div class='parent'>
    <div class='wrapper'>
        <div id='right-copy-1tomany' class='container'></div>
            <div id='left-copy-1tomany' class='container'>
                <div>TEST BOX 1</div>
                <div>TEST BOX 2</div>
                <div>TEST BOX 3</div>
                <div>TEST BOX 4</div>
                <div>TEST BOX 5</div>
            </div>
        </div>
    </div>
</div>

<h4>Dragule Code:</h4>

JS

dragula([document.getElementById(left), document.getElementById(right)],{
    accepts: function (el, target) {
    return target !== document.getElementById(right);
  },
    copy: function (el, source) {
    return source === document.getElementById(right);
  },
    removeOnSpill: true,
  }
});

【问题讨论】:

    标签: javascript html dragula


    【解决方案1】:

    dropModel() 事件中尝试使用el.remove()

     this.dragulaService.dropModel("<dragula-id>")
      .subscribe(({ name, el, target, source, sibling, sourceModel, targetModel, item }) => {
        if (<condition-to-remove>) {
           el.remove()
        }
      });
    

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 1970-01-01
      • 2020-07-27
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多