iteye_8232 2009-10-15 16:35
浏览 149
已采纳

ext 右键菜单

仿照例子粘贴代码搞了一个右键菜单 可是怎么我点击右键 没有任何反应 而且本身浏览器的默认右键菜单没有隐藏啊 代码如下:
Ext.onReady(
function(){
var tree=new Ext.tree.TreePanel({
el:'tree',
root : new Ext.tree.AsyncTreeNode({id:'-1',text:'广西电网公司'}),
loader : new Ext.tree.TreeLoader({dataUrl : '<%=request.getContextPath()%>/tree.do?ID=-1'})
});
//定义一个菜单
[color=red] new Ext.menu.Menu({
id:'contentMenu',
items:[{text:'我被单击啦',handler:function(){alert('我被单击啦。。啊');}}]
});[/color]
//将该菜单绑定到该树上
[color=red] tree.on('contentMenu',function(node,e){
e.preventDefault();//阻止浏览器默认右键菜单
node.select();//是该节点被选中状态
contentMenu.showAt(e.getXY());//获得鼠标的坐标
});[/color]
tree.render();
})

  • 写回答

2条回答 默认 最新

  • iteye_20589 2009-10-15 16:53
    关注

    [quote] //定义一个菜单
    new Ext.menu.Menu({
    id:'contentMenu',
    items:[{text:'我被单击啦',handler:function(){alert('我被单击啦。。啊');}}]
    });
    //将该菜单绑定到该树上
    tree.on('[color=red]contentMenu[/color]',function(node,e){
    e.preventDefault();//阻止浏览器默认右键菜单
    node.select();//是该节点被选中状态
    contentMenu.showAt(e.getXY());//获得鼠标的坐标 [/quote]
    你代码里面红色写错了。。右键事件不是contentMenu,而是contextmenu
    另外contentMenu.showAt(e.getXY());这个contentMenu是啥。。
    要contentMenu =Ext.menu.Menu({ ..});

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?