vendredi 23 mai 2014

Another simple contextmenu

Hi

I previously posted a thread asking about a contextmenu, however, here's another for you.



Code:



<!-- Begin ExtJS-->
<script type="text/javascript" charset="utf-8" async defer>
Ext.BLANK_IMAGE_URL = 'ext-4.2.1.883/resources/images/default/s.gif';
Ext.onReady(function(){
console.log("Congratulations! You have Ext configured correctly!");
var removeAction = Ext.create('Ext.Action', {
icon:'img/star_red.png',
text: 'Remove this element, because I don\'t like it',
handler: function(widget, event) {
if(confirm("This element will be removed from DOM. You will need to refresh your browser to make it reappear. Continue?")) {
Ext.get("elementContextMenu").remove();
}
return false;
}
});

var contextMenu = Ext.create('Ext.menu.Menu', {
items: [
removeAction
]
});
Ext.get("elementContextMenu").on("contextmenu", function(event,element){
event.stopEvent();
console.log(contextMenu.showAt(event.getXY()));
return false;
})
}); //end onReady
</script><div style="padding:15px;background:#EEE;border:3px solid #AAA;border-radius:10px;color:#000;width:500px;margin:50px" id="elementContextMenu">Right click here</div>

When I right click the div, nothing happens??


Aucun commentaire:

Enregistrer un commentaire