2

I am trying to use Martin Wendt's context menu control with FullCalendar in a similar manner to this question.

A context menu is supposed to appear whenever an event is right clicked but the problem is that I am getting the following javascript error in the chrome developer console.

jquery.min.js:3 Uncaught TypeError: ((r.event.special[g.origType] || {}).handle || g.handler).apply is not a function
    at HTMLDocument.dispatch (jquery.min.js:3)
    at HTMLDocument.q.handle (jquery.min.js:3)

I have set up an example jsfiddle to illustrate the problem. The full html example is listed below for future reference in case the link dies.

<html>
<head>
    <meta charset='utf-8' />
    <link href="../Scripts/assets/plugins/calendar/dist/fullcalendar.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../Content/jquery.contextMenu.min.css">

    <style>
        body {
            margin: 40px 10px;
            padding: 0;
            font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
            font-size: 14px;
        }

        #calendar {
            max-width: 900px;
            margin: 0 auto;
        }
    </style>
</head>
<body>

    <div id='calendar'></div>

    <script src='../Scripts/assets/plugins/jquery/jquery.min.js'></script>
    <script src="../Scripts/assets/plugins/calendar/jquery-ui.min.js"></script>
    <script src="../Scripts/assets/plugins/moment/moment.js"></script>

    <script src='../Scripts/assets/plugins/calendar/dist/fullcalendar.min.js'></script>

    <script src="../Scripts/jquery.contextMenu.min.js"></script>
    <script src="../Scripts/jquery.ui.position.js"></script>
    <script>

            $('#calendar').fullCalendar({
                defaultDate: '2019-08-12',
                editable: true,
                eventLimit: true,
                events: [
                    {
                        title: 'All Day Event',
                        start: '2019-08-01'
                    },
                    {
                        title: 'Long Event',
                        start: '2019-08-07',
                        end: '2019-08-10'
                    },
                    {
                        title: 'Conference',
                        start: '2019-08-11',
                        end: '2019-08-13'
                    },
                    {
                        title: 'Meeting',
                        start: '2019-08-12T10:30:00',
                        end: '2019-08-12T12:30:00'
                    }
                ]
                ,
                eventRender: function (event, element) {
                    var originalClass = element[0].className;
                    element[0].className = originalClass + ' hasmenu';
                },
                dayRender: function (day, cell) {
                    var originalClass = cell[0].className;
                    cell[0].className = originalClass + ' hasmenu';
                }
            })

            $(document).contextmenu({
                delegate: ".hasmenu",
                preventContextMenuForPopup: true,
                preventSelect: true,
                menu: [
                    { title: "Cut", cmd: "cut", uiIcon: "ui-icon-scissors" },
                    { title: "Copy", cmd: "copy", uiIcon: "ui-icon-copy" },
                    { title: "Paste", cmd: "paste", uiIcon: "ui-icon-clipboard", disabled: true },
                ],
                select: function (event, ui) {
                    // Logic for handing the selected option
                },
                beforeOpen: function (event, ui) {
                    ui.menu.zIndex($(event.target).zIndex() + 1);
                }
            });

    </script>

</body>
</html>
ADyson
  • 57,178
  • 14
  • 51
  • 63
Xtravia9
  • 63
  • 1
  • 8

1 Answers1

1

Looks like you are including the wrong library, at least if you want to use jquery-ui-contextmenu.

Try

<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="assets/jquery.ui-contextmenu.min.js"></script>

instead of

 <script src="../Scripts/jquery.contextMenu.min.js"></script>
mar10
  • 14,320
  • 5
  • 39
  • 64