Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if I've understood the whole of your question, but, in particular, I can help you with this part: </p> <p><em>"[...] to check if the node already exists in the tree not to allow the move"</em></p> <p>You must use, as you already were trying, the <a href="http://www.jstree.com/documentation/crrm" rel="nofollow noreferrer">crrm plugin</a>. I've just answered a <a href="https://stackoverflow.com/a/9843236/384351">pretty similar question</a>, with an example, maybe you'll want to take a look at it as well.</p> <p>In your case, as you need to check for a node's existence (or not) in another tree, you can do something like this:</p> <pre><code>"crrm": { "move": { "check_move": function(m) { return (m.ot === m.rt) || !m.rt.get_container().find("li[id="+m.o[0].id+"]").length; } } } </code></pre> <p>First we check if we are moving the node inside the same tree, and always allow this case (to reorder nodes or whatever). Change it if you don't need it.</p> <p>Then we check if the node exists:<br> <code>m.o</code> is the node being moved. You will seek for it in the tree where you're dropping the node.</p> <p><code>m.rt.get_container()</code> will return a jQuery DOM structure, so we just need to use <code>.find()</code> and it will return an array of <code>&lt;li&gt;</code> elements found by ID, being empty in the case nothing was found.</p> <p>If we return TRUE (we are moving around in the same tree, or the array is empty, that is, the node was not found in the second tree), the movement is allowed, otherwise it's disallowed.</p> <p>I hope it helps!</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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