例如,如何在不退回命令式样式cljs的情况下执行这些侦听器?
var cols = document.querySelectorAll('#columns .column');
[].forEach.call(cols, function(col) {
col.addEventListener('dragstart', handleDragStart, false);
col.addEventListener('dragenter', handleDragEnter, false);
col.addEventListener('dragover', handleDragOver, false);
col.addEventListener('dragleave', handleDragLeave, false);
});
答案 0 :(得分:4)
在线发现:https://www.refheap.com/73581
(defn allow-drop [e]
(.preventDefault e)) ;; because DnD in HTMl5 is crazy...
:draggable true ; -> otherwise the browser won't let you drag it
:on-drag-over allow-drop
:on-drag-enter allow-drop
:on-drag-start #(.setData (.-dataTransfer %) "text/plain" "") ;; for Firefox. You MUST set something as data.
:on-drag-end some-action
:on-drop some-other-action