I'm trying to call some javascript code when a context menu is show and is hidden (shown being when I right click and the context menu appears; hidden being when I click outside the context menu and it disappears from the page). I tried the following but the events never get fired.
// Create instance for tree
$(function () {
$('#myTree').jstree({
"core": {
"themes": {
'name': 'default',
"variant": "small",
"icons": false
}
},
"contextmenu": {
"items": getMenu(),
"select_node": false
}
,"plugins": ["contextmenu"]
});
});
// when context menu is shown
$("#myTree").bind('context_show.vakata', function (reference, element, position) {
// code to do...
});
// when context menu is hidden
$("#myTree").bind('context_hide.vakata', function (reference, element, position) {
// code to do...
});
The syntax appears correct according to the API. Please help with what I'm doing wrong.
As the API says - the events are triggered on the document, so replace:
$("#myTree").bind
with $(document).bind