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);
}
};
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
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With