禁用/启用 jQuery Dynatree 的上下文菜单不起作用
我正在使用 jQuery dynatree 以及此处<的上下文菜单< /a>.我遇到的问题是我无法启用/禁用上下文菜单或菜单中的单个项目。该插件说我应该能够做到这一点:
$("#contextMenu").enableContextMenu();
但这对我不起作用。这是菜单:
<!-- Definition of context menu -->
<div id="contextMenu">
<ul id="myMenu" class="contextMenu">
<li class="resubmit"><a href="#resubmit">Resend</a></li>
</ul>
</div>
如果我不进行任何启用/禁用操作,菜单会显示并正常工作,但在某些情况下菜单项不可用,因此我需要能够控制其状态。如果我输入启用/禁用,则根本不会显示菜单。
谁能分享一下他们是如何让它发挥作用的?
更新:如果删除上面的 DIV,我只能显示菜单。然后它会显示,但使用“myMenu”启用/禁用没有任何作用......
I am using the jQuery dynatree along with the context menu found here. The issue I'm having is that I can't get the enable/disable of the context menu or individual items in the menu to work. The plugin says I should be able to do this:
$("#contextMenu").enableContextMenu();
but that doesn't work for me. Here's the menu:
<!-- Definition of context menu -->
<div id="contextMenu">
<ul id="myMenu" class="contextMenu">
<li class="resubmit"><a href="#resubmit">Resend</a></li>
</ul>
</div>
The menu shows and works fine if I don't put any enable/disable, but there are cases where the menu item is not available so I need to be able to control its state. If I put in the enable/disable, the manu doesn't show at all.
Can anyone share how they got this to work?
UPDATE: I can only get the menu to show if I remove the DIV above. Then it will show, but enable/disable using "myMenu" does nothing...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遇到同样的问题,您实际上可以禁用上下文菜单触发器,例如:
并使用 True 重新启用它。 dynatree-title 是触发器绑定到的元素。
希望这可以帮助其他偶然发现此问题的人。
上下文菜单文档
Came across the same issue, you can actually disable the context menu trigger like:
And re-enable it with True. dynatree-title being the element the trigger is bound to.
Hope this helps anyone else who stumbles across this.
Context menu documentation
我无法禁用菜单本身,因此我必须在选择项目后处理它:
我只需检查是否选择了正确的类型节点才能执行操作(查看父级,即包含的文件夹)。
I couldn't disable the menu itself, so I had to handle it after the item is selected:
I just check that the proper type node is selected to be able to take the action (look at parent, which is the containing folder).