【发布时间】:2013-06-18 06:59:20
【问题描述】:
我尝试将上下文菜单绑定到我的 jsTree。
Not so helpful JSFiddle, because context menu works in it
我添加了 contextmenu 插件,但右键单击时不显示菜单。于是我调试了渲染上下文菜单的函数,发现菜单元素的高度和宽度都是0。我也在this page上调试了一个例子,发现高度和宽度都是正数。
// Height and width are 0 in my app and jsTree example.
$.vakata.context.cnt
.html(html) // Default menu, so HTML in my app and in example are the same.
.css({ "visibility" : "hidden", "display" : "block", "left" : 0, "top" : 0 });
...
h = $.vakata.context.cnt.height(); // 0 in my app, > 0 in example.
w = $.vakata.context.cnt.width(); // 0 in my app, > 0 in example.
可能的原因是什么?
已解决
当应用程序初始化时,它会清理为显示上下文菜单而创建的 jsTree。
很抱歉打扰。
【问题讨论】:
-
请提供一个示例性的 jsfiddle
-
@Alp,我提供了示例,但我的问题是上下文菜单在我的应用程序中不起作用,问题未在 jsFiddle 中重现。
-
@Marboni 根据您的最后评论,您的应用程序中一定存在错误。除非您向我们提供完整的来源,否则没有人可以帮助您解决这个问题。顺便说一句,您浪费了 100 个声望...
-
你说得对,@cept0,我找到了原因。 jsTree 在准备好的文档上创建 div,然后我的应用程序清理了主体以重新绘制布局。我支付了 100 声望来学习如何提出正确的问题。 :)
标签: javascript jstree