Jstree How to change "New node" shortcut when creating a new node?
I am using the contextmenu plugin when creating a new node and then have my own function to create a new node using an ajax message.
$("#tree").jstree({
//....
"plugins": ["themes", "json_data", "crrm", "contextmenu", "dnd", "ui", "cookies"]
})
//...
.bind("create.jstree", function (e, data) {
//...
$.ajax({
type: "POST",
//...
});
});
I would like to change the default label "New node" to "New folder" when clicking "New". Any help would be appreciated.
+3
source to share
5 answers
Here you can change the context menu options
$("#tree").jstree({
"plugins": ["themes", "html_data", "ui", "crrm", "contextmenu"],
"contextmenu": {
"items": function ($node) {
return {
"Create": {
"label": "New Folder",
"action": function (obj) {
this.create(obj);
}
}
};
}
}
});
Update
You can find this part in jquery.jstree.js file
if(!js.data) { js.data = this._get_string("new_node"); }
change this part to
if(!js.data) { js.data = this._get_string("new folder"); }
+3
source to share
Thank you for your help. I changed the new node to a new folder in the default jquery.jstree.js file and it worked. Thanks again.
$.jstree.plugin("core", {
__init : function () {
this.data.core.locked = false;
this.data.core.to_open = this.get_settings().core.initially_open;
this.data.core.to_load = this.get_settings().core.initially_load;
},
defaults : {
html_titles : false,
animation : 500,
initially_open : [],
initially_load : [],
open_parents : true,
notify_plugins : true,
rtl : false,
load_open : false,
strings : {
loading : "Loading ...",
new_node : "New folder",
multiple_selection : "Multiple selection"
}
},
0
source to share