In Reagent of Clojurescript, how do I add event listeners for drag and drop?

例如,我如何执行这些监听器而不会回到命令式风格的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);
});

在线找到: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
链接地址: http://www.djcxy.com/p/78588.html

上一篇: 在使用ng后附加一个处理程序

下一篇: 在Clojurescript的试剂中,我如何添加事件监听器进行拖放?