I am using jsTree to build a knowledge base for a customer support service. For this, I need to be able to send contents from each node to any of currently active users on my website.
This means that each time I call a context menu for a node, I need it to get currently active users via ajax, and then display them as menu items.
Now, I know that contextmenu is a function of node. But how to bind it to the results of an ajax function?
Something along the lines of:
"contextmenu": {
"select_node": false,
"show_at_node": false,
"items": function(node) {
$.ajax({
url: 'some_url_with_actions_for_node',
success: function (action_list) {
return action_list;
}
})
}
}
obviously the example above won't work, but you get the idea.
The docs say that the menu can be
a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too)
so maybe there's a way to squeeze in the callback I need? I am just too bad at JS to figure this out.