显示和隐藏上下文菜单时的 Jstree 调用事件
Jstree call event when context menu is shown and hidden
我正在尝试在显示和隐藏上下文菜单时调用一些 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
此致,
伊万
我正在尝试在显示和隐藏上下文菜单时调用一些 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
此致, 伊万