gpt4 book ai didi

jquery - 将上下文菜单与 FullCalendar 结合使用

转载 作者:行者123 更新时间:2023-12-01 04:35:22 24 4
gpt4 key购买 nike

我正在尝试使用 Martin Wendt 的上下文菜单控件 FullCalendar以类似的方式 this question .

只要右键单击某个事件,就会出现上下文菜单,但问题是我在 Chrome 开发者控制台中收到以下 JavaScript 错误。

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)

我设置了一个例子jsfiddle来说明问题。下面列出了完整的 html 示例,以供将来引用,以防链接失效。

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

最佳答案

看起来您包含了错误的库,至少如果您想使用jquery-ui-contextmenu .

尝试

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

而不是

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

关于jquery - 将上下文菜单与 FullCalendar 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58014488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com