This should be a really simple question, but I can't seem to find the answer anywhere. I've recently (like today) began using jsTree and I just got my first tree set up. I created an unordered list of just static text:
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
My code to do a jsTree looks like this:
$(document).ready(function () {
$("#demo1").bind("select_node.jstree",
function(event, data) {
//DO SOMETHING WHEN A NODE IS CLICKED
}).jstree();
});
Then I try to add a context menu. Using the following:
$(document).ready(function () {
$("#demo1").bind("select_node.jstree",
function(event, data) {
//DO SOMETHING WHEN A NODE IS CLICKED
}).jstree({plugins: ["contextmenu"], contextmenu: {items: customMenu}});
});
customMenu is a simple function that returns an object.
When I execute the first code, I get my jsTree and it collapses and expands. When I execute the second one, the area where the jsTree is says "Loading..." and that is all. If I right-click that word, I DO get the menu.
Any suggestions?
if, when I point it to the function customMenu, I add the (), then I get a really strange menu that has: -create -rename -delete -edit --cut --copy --paste --Add Group --delete
I'm not sure I know what's going on. I changed the function name to something different to be sure I wasn't getting a jQuery or jsTree function, but I still get the strange behavior. Any suggestions?