gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:13:46 25 4
gpt4 key购买 nike

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

也许我在类似的事情上走在正确的轨道上?

x = [];

Template.dragulaTemplate.events({
"drop #right1": function(el) {
x.push(el);
}
});

最佳答案

我认为您不能将 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);
});
});

关于javascript - 如何使用 Meteor-Dragula 将容器的内容推送到数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34042660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com