我有一個樹形視圖,我想爲不同的項目添加右鍵單擊支持。這是我做的:顯示菜單時,右鍵點擊樹形視圖的項目
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分鐘!小甜心布魯夫! –