org.nasdanika.html.jstree.impl.ajaxTreeWithContextMenu.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstree Show documentation
Show all versions of jstree Show documentation
Classes for generating JsTree nodes and context menus.
{
'core' : {
'data' : {
'url' : function (node) {
return {{nodesUrl}}; // Expression, use node.id to access node id.
},
'data' : function (node) {
return { 'id' : node.id };
}
}
},
'plugins' : [ 'contextmenu' ],
'contextmenu' : {
'items' : function(node, callback) {
$.getJSON({{contextMenuUrl}}, function(data, status) { // Expression, use node.id to access node id.
if ("success" == status) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
var item = data[key];
if (item.action) {
item.action = function(action) { eval(action); }.bind(item, item.action);
}
}
}
callback(data);
} else {
console.error("Error loading context menu: "+status);
}
});
}
}
}