0
我想在我的頁面中實現一個上下文菜單。該腳本運行良好,但現在我想要打開一個模式,當我從上下文菜單中單擊某個seccion時。如何從ContextMenu打開模態(單擊鼠標右鍵)?
我有以下HTML:
<!-- Body -->
<div id="contextMenu" class="content right-click">
</div>
和jQuery代碼:
<!-- Context Menu (Right Click) -->
<script src="../../plugins/contextMenu/js/contextmenu.min.js"></script>
<script type="text/javascript">
var $div = $('#contextMenu');
// ContextMenu instance
var cm = new ContextMenu({
selector: '.right-click',
callback: function(cmd, options) {
switch (cmd) {
case 'SetLayer':
$div[0].style.backgroundColor = 'red';break;
case 'SetProjection':
$div[0].style.backgroundColor = 'blue';break;
}
},
items: [
{
text: 'Set Map',
items: [
{
text: 'Set Layer',
cmd: 'SetLayer',
target: '_blank',
url: ''
}, {
text: 'Set Projection',
cmd: 'SetProjection',
target: '_blank',
url: ''
}
]
}
]
});
</script>
我試圖插入下面的jQuery代碼爲 'SetProjection':
$('#projectionModal').dialog('open');break;
但沒有成功。順便說一句,當我點擊SetLayer或SetProjection時,我可以改變BackGroundColor。
它更容易幫助,如果你把你的代碼中的jsfiddle:HTTPS ://jsfiddle.net/ – sdeburca