如何使用Meteor-Dragula将容器的内容推送到数组中?

时间:2015-12-02 12:23:00

标签: javascript meteor dragula

我正在使用Meteor-Dragula。让我们说我将一个包含字符串Slide的容器拖到hello DOM元素中。我如何访问该字符串?比如说,将其推入String数组中。

也许我已经走上了正确的道路?

#right

1 个答案:

答案 0 :(得分:1)

我认为你不能使用Meteor事件Meteor-Dragula。相反,您需要使用 drake.on 才能注册事件侦听器。例如:

x = [];
Template.dragulaTemplate.onRendered(function() {
  var drake = dragula([document.querySelector('#left1'), document.querySelector('#right1')]);
  drake.on('drop', function(el, target, source, sibling) {
    x.push($(el).text());
    console.log(x);
  });
});