PDA

View Full Version : Context menu appearing in the middle of screen, attached code



jlimaye
15 Dec 2011, 9:55 PM
Hi,
I have attached contextmenu for div tag. But Im not able to place the menu near that tag, its appearing in the center of screen.



<html>
<head>
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="../css/ext-all.css" />
<script type="text/javascript" src="../js/ext-base.js"></script>
<script type="text/javascript" src="../js/ext-all-debug.js"></script>

</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {

Ext.BLANK_IMAGE_URL = '../images/s.gif';
Ext.get('div1').on('contextmenu', function(eventObj, elRef) {
eventObj.stopEvent();
if (!this.contextmenu) {
this.contextmenu = new Ext.menu.Menu({
// floating : false,
// renderTo : Ext.get('div1'),
items : [{
text : "A"
},{
text : "B"
},{
text : "C"
}]
});
}
this.contextmenu.show();
});



});
</script>
<div id='div1'>asdf</div>
</body>
</html>

What am I doing wrong???

tvanzoelen
16 Dec 2011, 1:11 AM
You can use use show at and leave the render to div out



this.contextmenu = new Ext.menu.Menu({
// floating : false,

items : [{
text : "A"
},{
text : "B"
},{
text : "C"
}]
});

this.contextmenu.showAt(eventObj.getXY())

jlimaye
16 Dec 2011, 1:15 AM
ok, thanks.. worked out..