Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if the edit mode in jstree is on? Is it possible to check it?

Tags:

jstree

I am using jsTree and I want to get the name/value/text of the node I just created so that I can pass it and store it in the database. My problem is that after enabling the edit mode, I have no wayof getting the value entered by the user. My idea is that if I can only determine if the edit mode is on or off, then I can kinda run a function that will now get the user's input. I included here the function for creating the node.

Any other way to solve this problem is much appreciated. Thanks in advance.

function demo_create(){
            var ref = $('#data').jstree(true),
            p_id = sel = ref.get_selected();
            console.log("Parent Id: "+p_id);   
            if(!sel.length) { return false; }
            sel = sel[0];
            id = sel = ref.create_node(sel, {"type":"file"});
            console.log("Newly Created Id: "+id);
            if(sel) {
                ref.edit(sel);
            }
        };
like image 693
maysensei Avatar asked Dec 05 '25 10:12

maysensei


1 Answers

edit will fire the rename_node.jstree once the node name is changed.

You can also use the callback of edit:

ref.edit(sel, null, function (node, status) {
    console.log(node.text); // the new node title
})
like image 114
vakata Avatar answered Dec 08 '25 22:12

vakata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!