Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For #1, you need to make your <code>drop</code> function just a little bit more intelligent. Inside of it, check to make sure that there are no <code>childNodes</code> before appending the Child.</p> <p>For #2, you need to make both <code>drag</code> and <code>drop</code> more intelligent. In <code>drag</code>, you need to look at the target and set some group information. In <code>drop</code>, you need to check that information to see if it matches appropriately.</p> <p>I can show you what #1 should look like:</p> <pre><code>function drop(ev) { ev.preventDefault(); if (ev.target.hasChildNodes()) { return; } // ...all the rest as you had it </code></pre> <p>For #2, it will be a bit more complex, depending on how you want to define the second set of icons. Generally, it should make your code look something like this:</p> <pre><code>function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); // I'm going to assume your group1 items will have "group1" in their id. Set it up however you want. if (ev.target.id.indexOf("group1") != -1) { ev.dataTransfer.setData("Group", 1); } else { ev.dataTransfer.setData("Group", 2); } // ...all the rest as you had it } function drop(ev) { ev.preventDefault(); if (ev.target.hasChildNodes()) { return; } if (ev.target.id.indexOf("group1") != -1 &amp;&amp; ev.dataTransfer.getData("Group") == 2 || ev.target.id.indexOf("group2") != -1 &amp;&amp; ev.dataTransfer.getData("Group") == 1) { return; } // ...all the rest as you had it </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload