我有一个树形视图,我想为不同的项目添加右键单击支持。这是我做的:显示菜单时,右键点击树形视图的项目
http://jsfiddle.net/doonot/xWjSz/
菜单显示仅对第一根模块(后右单击),但不是根本的其余模块。你能告诉我我必须改变什么,为了获得所有根模块的菜单吗?
非常感谢,我非常感谢您的回答。
我有一个树形视图,我想为不同的项目添加右键单击支持。这是我做的:显示菜单时,右键点击树形视图的项目
http://jsfiddle.net/doonot/xWjSz/
菜单显示仅对第一根模块(后右单击),但不是根本的其余模块。你能告诉我我必须改变什么,为了获得所有根模块的菜单吗?
非常感谢,我非常感谢您的回答。
你好请参阅本演示http://jsfiddle.net/hYJPv/1/或http://jsfiddle.net/hYJPv/(修正问题)或这里http://jsfiddle.net/UeqBk/for_Dooonot_from_Tats_innit/
差异的方法上rightclick
你会得到一个警告。
代码
$(document).ready(function()
{
// If you want to disable showing the context menu when right clicking
// on the document, the code below would do the trick.
$(document).bind("contextmenu",function(e)
{
alert('right click capture');
return false;
});
var $tree = $("#tree").kendoTreeView(
{
select: function (event)
{
var $item = $(event.node);
console.log($item);
alert("selected");
}
});
// Find the item you want to select...
var $selected = $('#selected');
var $treePath = $selected.parentsUntil($tree, "li");
var treeView = $tree.data('kendoTreeView');
// Expand the tree in order to show the selected item
treeView.expand($treePath);
// Gotta make both calls...
treeView.select($selected);
treeView.trigger('select', {node: $selected});
});
非常感谢!但我不确定这是否真的是我需要的。我能够捕捉到正确的点击,甚至显示菜单,但仅限于树视图中的第一项。它不适用于其他项目。我不知道该怎么做。你知道吗? – doonot
@doonot没有probs布鲁夫,你的意思是我给你的例子还是你的例子?对不起,如果这听起来有点密集:Pjust确保我明白你的意思!麦片! –
在我提供的示例中。我实际上使用这个[教程](http://www.webdeveloperjuice.com/2010/02/22/create-simple-jquery-right-click-cross-browser-vertical-menu/)。 – doonot
你好那里,我可以给你一个很简单的jsfiddle会为你的工作会捕捉你的右键点击?请让我知道如果这适合你bruv会更新使用树视图的答案,有一个不错的:) cheerios! –
是的,这将是非常好的。给我一分钟,我会在上面添加我的树视图的一部分!顺便说一句,我正在使用jquery-treeview。 – doonot
Saweet gimme 2分钟!小甜心布鲁夫! –