JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://medialize.github.com/jQuery-contextMenu/src/jquery.ui.position.js"></script>
<script src="http://medialize.github.com/jQuery-contextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" href="http://medialize.github.com/jQuery-contextMenu/src/jquery.contextMenu.css">
<div class="context-menu-one box menu-1">
<strong>right click me</strong>
</div>
CSS
/* demo trigger boxes */
.box {
color: #EEE;
background: #666;
font-weight: bold;
padding: 20px;
text-align: center;
font-size: 20px;
margin: 5px 0;
}
.box:hover {
background: #777;
}
.box > * {
display:block;
}
.menu-injected { background-color: #C87958; }
.box.context-menu-disabled { background-color: red; }
JavaScript
$(function(){
function createSomeMenu() {
return {
callback: function(key, options) {
var m = "clicked: " + key;
window.console && console.log(m) || alert(m);
},
items: {
"edit": {name: "Edit", icon: "edit"},
"cut": {name: "Cut", icon: "cut"},
"copy": {name: "Copy", icon: "copy"}
}
};
}
// some asynchronous click handler
$('.context-menu-one').on('mouseup', function(e){
var $this = $(this);
$this.data('runCallbackThingie', createSomeMenu);
setTimeout(function(){ $this.contextmenu(); }, 3000);
});
// setup context menu
$.contextMenu({
selector: '.context-menu-one',
ignoreRightClick: true,
build: function($trigger, e) {
return $trigger.data('runCallbackThingie')();
}
});
});