JavaScript Getting elemens id of a jstree on drag and drop

I have 2 jstrees and now I am trying to implement a drag and drop option between them, but I can't seem to manage to obtain the id's of the element i am dragging or the new parent's id (after drag and drop). Until now this is the code I created, but in the data that i alert there are no ids or any other info that would help me.

$("#tree").jstree({


   "dnd" : {

        "drop_finish" : function(data) {
            alert(data.toSource());
        }
       },
   "plugins" : [ "themes", "html_data", "dnd", "ui", "types" ],
});

I have also created a working Fiddle with 2 trees and pretty much all my code.

If anyone could give me a hint or an idea about how could I solve this problem, I would greatly appreciate it.

Answer:1

Try this

$("#tree").bind('move_node.jstree', function(e, data) {
    alert(data.node.id);
    alert(data.parent);
    alert(data.old_parent);
    alert(data.position);
}

Theese variables are pretty much self-explanatory.

Answer:2

Don't use "dnd", let try "crrm" like this.

"crrm": {
        "move": {
            "always_copy": "multitree",//create a copy node,prevent removing node
            check_move: function(m) {
                // use m.ot,m.rt to get the id of the node you are dragging or the node you will drop down.
            }
            ,"default_position": "last"
        }
    },

Please read jstree documentation before. I had spent more time to learn it.So try to read the documentation,all of you want is in it.

Answer:3

Here is my code so far: dojoConfig = {parseOnLoad: true}; resetStopwatch(); require(["dojo/query", "dijit/form/ToggleButton", "dijit/form/Button", "dojo/dom", "dojo/dom-attr", "dojo/...

Here is my code so far: dojoConfig = {parseOnLoad: true}; resetStopwatch(); require(["dojo/query", "dijit/form/ToggleButton", "dijit/form/Button", "dojo/dom", "dojo/dom-attr", "dojo/...

  1. change button text javascript
  2. change button text on click
  3. change button text jquery
  4. change button text color
  5. change button text swift
  6. change button text unity
  7. change button text css
  8. change button text color swift
  9. change button text color css
  10. change button text tkinter
  11. change button text excel
  12. change button text onclick react
  13. change button text android studio
  14. change button text on hover
  15. change button text vba
  16. change button text size
  17. change button text color bootstrap
  18. change button text java
  19. change button text color react native
  20. change button text squarespace

This is not something I'm actually going to use, I know I should not have two headers on a page, this is just an example of my problem. This works perfectly when there is only one on the page, but ...

This is not something I'm actually going to use, I know I should not have two headers on a page, this is just an example of my problem. This works perfectly when there is only one on the page, but ...

  1. moving elements around javascript
  2. jquery moving elements around

I'm trying to execute a piece of code within an empty isolated execution context in JavaScript. In the below sample, I'm trying isolate isolated execution scope. What I want to do is to execute a ...

I'm trying to execute a piece of code within an empty isolated execution context in JavaScript. In the below sample, I'm trying isolate isolated execution scope. What I want to do is to execute a ...

  1. isolated execution context

How can I access the binary representation with JavaScript from a file uploaded with a file input?: <input type="file" name="file"> I can access the details of the uploaded file successfully ...

How can I access the binary representation with JavaScript from a file uploaded with a file input?: <input type="file" name="file"> I can access the details of the uploaded file successfully ...

  1. file input value html
  2. file input value jquery
  3. file input value javascript
  4. file input value react
  5. file input value
  6. file input value fakepath
  7. file input value php
  8. file input value clear
  9. file input value display
  10. input file value set
  11. input file value reset
  12. input file value default
  13. input file value change
  14. input file value base64
  15. input file value laravel
  16. input file value change event
  17. input file value url
  18. input file value empty
  19. input file value get
  20. input file value angular