如何使用 Meteor-Dragula 将容器的内容推送到数组中?
How to push the content of a container into an array using Meteor-Dragula?
我正在使用 Meteor-Dragula。假设我将一个包含字符串 hello
的容器拖到 #right
DOM 元素中。我如何访问该字符串?比如说,将它推入一个 String 数组。
也许我做这样的事情是对的?
x = [];
Template.dragulaTemplate.events({
"drop #right1": function(el) {
x.push(el);
}
});
我认为您不能使用 Meteor-Dragula. Instead, you'll need to use drake.on
的 Meteor 事件来注册事件侦听器。例如:
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);
});
});
我正在使用 Meteor-Dragula。假设我将一个包含字符串 hello
的容器拖到 #right
DOM 元素中。我如何访问该字符串?比如说,将它推入一个 String 数组。
也许我做这样的事情是对的?
x = [];
Template.dragulaTemplate.events({
"drop #right1": function(el) {
x.push(el);
}
});
我认为您不能使用 Meteor-Dragula. Instead, you'll need to use drake.on
的 Meteor 事件来注册事件侦听器。例如:
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);
});
});