2

I want to implement a context menu in my page. The script is working good, but Now I'd like open a modal when I do click some seccion from context menu.

I have the following HTML:

<!-- Body -->
<div id="contextMenu" class="content right-click">
</div>

and jQuery code:

    <!-- 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>

I've tried to insert the following jQuery code into 'SetProjection':

$('#projectionModal').dialog('open');break;

But without-success.

By the way, when I do click on SetLayer or SetProjection I can change the BackGroundColor.

1
  • It's easier to help if you put your code in a jsfiddle: jsfiddle.net
    – sdeburca
    Commented Jul 9, 2015 at 21:22

1 Answer 1

1

It was really stupid... The only thing I had to change in the code:

$('#projectionModal').dialog('open');break;

to

$('#projectionModal').modal('show');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.