Question

For example, how do I perform these listener without falling back into imperative style 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);
});
Was it helpful?

Solution

Found this online: 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top