我试图在上下文菜单显示和隐藏时调用一些javascript代码(显示是当我右键单击并且上下文菜单出现时;隐藏是当我单击上下文菜单外部并且它从页面中消失时) 。我尝试了以下操作,但事件从未被解雇。
// 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...
});
根据 API,语法显示正确。请帮助解决我做错的事情。
正如 API 所说 - 事件在文档上触发,因此替换:
$("#myTree").bind
与 $(document).bind