see the attached image
for above treeview menu code :
ret = "<ul id='navigation1'>"
tree.each do |node|
# if node.InstallationName == parent_id
ret += "<li>"
ret += link_to_remote(node.InstallationName, :url => {:controller => "ptcgeodatabase", :action => "page_node"},
:with => "'installation_name_delete='+'#{node.InstallationName开发者_开发问答}'",:update => "mcfcontent1")
Geoptcmenu.connectdb($mantmasterdblocation)
sub = Geoptcmenu.find(:all,:select=>'Distinct MCFName',:conditions=>['InstallationName=?', node.InstallationName])
ret += display_mcftree_child(sub, node.InstallationName)
ret += "</li>"
# end
end
ret += "</ul>"
and for show context menu while right click i have written code :
$('#navigation1').contextMenu('context-menu-1', {
'Delete Installation': {
click: function(element) { // element is the jquery obj clicked on when context menu launched
$.post("/ptcgeodatabase/deletemcf", {
}, function(data){
window.location.href = "/ptcgeodatabase/ptcgeo_mcfextractor"
});
},
klass: "ocemenu-item-1" // a custom css class for this menu item (usable for styling)
}});
i am not able to get the which element i have right clicked . is any way to get name of right clicked element?
ret = "<ul id='navigation1'>"
tree.each do |node|
# if node.InstallationName == parent_id
ret += "<li>"
ret += link_to(node.InstallationName, "#")
Geoptcmenu.connectdb($mantmasterdblocation)
sub = Geoptcmenu.find(:all,:select=>'Distinct MCFName',:conditions=>['InstallationName=?', node.InstallationName])
ret += display_mcftree_child(sub, node.InstallationName)
ret += "</li>"
# end
end
ret += "</ul>"
$(function() {
$('#navigation1 li').mousedown(function(event) {
var selectedelementid = this.id;
if (selectedelementid) {
switch (event.which) {
case 1:
//alert('Left mouse button pressed');
$('#navigation1 li').removeClass('selected');
$(this).addClass('selected');
$.post("/ptcgeodatabase/page_node", {
installation_name_delete: selectedelementid
});
break;
case 2:
var message ="<div style="+"padding-top:30px;padding-left:5px;color:red;padding-right:5px;padding-bottom:10px;font-size:small;"+">You have clicked middle mouse button</div>";
$.colorbox({html:message ,transition:"none" ,width:"300px" ,height:"150px"});
//alert('You have clicked middle mouse button.');
break;
case 3:
//alert('Right mouse button pressed');
$('#navigation1 li').removeClass('selected');
$(this).addClass('selected');
$.post("/ptcgeodatabase/page_node", {
installation_name_delete: selectedelementid
});
break;
default: break;
}
}
});
});
精彩评论