Jquery FullCalendar-dayRender在';移除事件';呼叫

Jquery FullCalendar-dayRender在';移除事件';呼叫,jquery,fullcalendar,Jquery,Fullcalendar,我正在ASP.NET MVC应用程序中使用FullCalendar v1.6.4(作为模拟) 一方面,我实现了“dayRender”回调以引入“cell.bind('dblclick',function(){…})”;(通过双击day单元格添加事件) 另一方面,我实现了“eventClick”回调,以在单击事件时显示KendoUI窗口弹出窗口 在这个窗口中,我有一些编辑控件&2个按钮:一个用于使用编辑控件中的新值修改事件,另一个用于删除事件 “删除”按钮启动“removeEvents”回调,将当

我正在ASP.NET MVC应用程序中使用FullCalendar v1.6.4(作为模拟)

一方面,我实现了“dayRender”回调以引入“cell.bind('dblclick',function(){…})”;(通过双击day单元格添加事件)

另一方面,我实现了“eventClick”回调,以在单击事件时显示KendoUI窗口弹出窗口

在这个窗口中,我有一些编辑控件&2个按钮:一个用于使用编辑控件中的新值修改事件,另一个用于删除事件

“删除”按钮启动“removeEvents”回调,将当前事件删除到日历中

所有这些都可以正常工作,但当我处理完删除事件后,就无法添加新事件

“dblclick”事件似乎触发得很好(我已经放置了一些JS警报进行测试)。我在Chrome调试器中没有发现javascript错误:s

有人知道我哪里错了吗

这是我的密码:

@{
    ViewBag.Title = "Mock";
}

<h2 class="content-title">Mock</h2>

<div class="divSetAddedActivity">
    <input id="ddlMissions" style="width: 250px" />
    <input id="tbxDuration" type="number" value="8" min="1" max="24" step="1" />
    <textarea rows="1" cols="50" id="tbxComment" placeholder="Add a comment"></textarea>
</div>

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

<div id="window">
    <p id="activityDate"></p>
    <input type="hidden" id="itemId"/>
    <input id="ddlMissions2" style="width: 250px" />
    <input id="tbxDuration2" type="number" min="1" max="24" step="1" />
    <textarea rows="1" cols="50" id="tbxComment2" placeholder="Add a comment"></textarea>
    <button id="btnModifyActivity">Modify</button>
    <button id="btnDeleteActivity">Delete</button>
</div>

<script>
    jQuery(document).ready(function () {
        var window = $("#window");

        $("#tbxDuration").kendoNumericTextBox({
            format: "# h",
            decimals: 0
        });
        $("#tbxDuration2").kendoNumericTextBox({
            format: "# h",
            decimals: 0
        });

        if (!window.data("kendoWindow")) {
            window.kendoWindow({
                width: "500px",
                visible: false,
                modal: true,
                title: "Modify activity"
            });
        }

        var today = new Date();
        var d = today.getDate();
        var m = today.getMonth();
        var y = today.getFullYear();

        var userEvents = [];

        var missions = [{ Id: 1, DisplayLabel: 'Mission1' },
                        { Id: 2, DisplayLabel: 'Mission2' },
                        { Id: 3, DisplayLabel: 'Mission3' },
                        { Id: 4, DisplayLabel: 'Mission4' },
                        { Id: 5, DisplayLabel: 'Mission5' },
                        { Id: 6, DisplayLabel: 'Mission6' },
                        { Id: 7, DisplayLabel: 'Mission7' },
                        { Id: 8, DisplayLabel: 'Mission8' }];

        jQuery("#ddlMissions").kendoDropDownList({
            dataSource: missions,
            dataTextField: "DisplayLabel",
            dataValueField: "Id"
        });
        jQuery("#ddlMissions2").kendoDropDownList({
            dataSource: missions,
            dataTextField: "DisplayLabel",
            dataValueField: "Id"
        });

        jQuery('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: ''
            },
            editable: true,
            firstDay: 1,
            eventClick: function(calEvent, jsEvent, view) {
                jQuery("#itemId").val(calEvent.id);
                jQuery("#activityDate").text(calEvent.start);
                jQuery("#ddlMissions2").data("kendoDropDownList").value(calEvent.missionId);
                jQuery("#tbxDuration2").val(calEvent.duration);
                jQuery("#tbxComment2").val(calEvent.comment);

                window.data("kendoWindow").open();
                window.data("kendoWindow").center();
            },
            eventMouseover: function (calEvent, jsEvent) {
                var tooltip = '<div class="tooltipevent" style="width:150px;background:rgb(159,201,175);position:absolute;z-index:10001;"><b>' + calEvent.title + '</b><br/>'+ calEvent.duration + 'h<br/><i>' + calEvent.comment +'</i></div>';
                $("body").append(tooltip);
                $(this).mouseover(function (e) {
                    $(this).css('z-index', 10000);
                    $('.tooltipevent').fadeIn('500');
                    $('.tooltipevent').fadeTo('10', 1.9);
                }).mousemove(function (e) {
                    $('.tooltipevent').css('top', e.pageY + 10);
                    $('.tooltipevent').css('left', e.pageX + 20);
                });
            },

            eventMouseout: function (calEvent, jsEvent) {
                $(this).css('z-index', 8);
                $('.tooltipevent').remove();
            },
            eventRender: function(event, element) { 
                element.find('.fc-event-title').append("<br/>" + event.duration + "h"); 
                element.find('.fc-event-time').hide();
            },
            dayRender: function (date, cell) {
                cell.bind('dblclick', function () {
                    var ddlMissions = $("#ddlMissions").data("kendoDropDownList");
                    var numDuration = $("#tbxDuration").data("kendoNumericTextBox");

                    alert('a');
                    userEvents.push({
                        id: userEvents[userEvents.length - 1].id + 1,
                        title: ddlMissions.text(),
                        missionId: ddlMissions.value(),
                        start: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
                        allDay: false,
                        duration: numDuration.value(),
                        comment: jQuery("#tbxComment").val(),
                        color: "green"
                    });
                    alert('b');

                    jQuery('#calendar').fullCalendar('refetchEvents');
                    alert('c');
                });
            },
            events: userEvents
        });

        jQuery("#btnModifyActivity").click(function () {
            var currentId = jQuery("#itemId").val();
            var activity = jQuery.grep(userEvents, function (e) { return e.id == currentId; })[0];
            activity.title = jQuery("#ddlMissions2").data("kendoDropDownList").text();
            activity.missionId = jQuery("#ddlMissions2").data("kendoDropDownList").value();
            activity.duration = jQuery("#tbxDuration2").val();
            activity.comment = jQuery("#tbxComment2").val();

            for (var i = 0; i < userEvents.length; i++) {
                if (userEvents[i].id === activity.id) {
                    userEvents[i] = activity;
                }
            }
            jQuery('#calendar').fullCalendar('refetchEvents');
            window.data("kendoWindow").close();
        });

        jQuery("#btnDeleteActivity").click(function () {
            var currentId = jQuery("#itemId").val();
            jQuery('#calendar').fullCalendar('removeEvents', [currentId]);
            jQuery('#calendar').fullCalendar('refetchEvents');
            window.data("kendoWindow").close();
        });
    });
</script>
@{
ViewBag.Title=“Mock”;
}
嘲弄

修改 删除 jQuery(文档).ready(函数(){ 变量窗口=$(“#窗口”); $(“#tbxDuration”).kendonumeric文本框({ 格式:“h”, 小数:0 }); $(“#tbxDuration2”).kendonumeric文本框({ 格式:“h”, 小数:0 }); 如果(!window.data(“kendoWindow”)){ window.kendoWindow({ 宽度:“500px”, 可见:假, 莫代尔:是的, 标题:“修改活动” }); } var today=新日期(); var d=today.getDate(); var m=today.getMonth(); var y=today.getFullYear(); var userEvents=[]; var任务=[{Id:1,DisplayLabel:'Mission1'}, {Id:2,显示标签:'Mission2'}, {Id:3,显示标签:'Mission3'}, {Id:4,显示标签:'Mission4'}, {Id:5,显示标签:'Mission5'}, {Id:6,显示标签:'Mission6'}, {Id:7,显示标签:'Mission7'}, {Id:8,显示标签:'Mission8'}]; jQuery(“#ddl”).kendoDropDownList({ 数据来源:任务, dataTextField:“显示标签”, dataValueField:“Id” }); jQuery(“#ddlMissions2”).kendoDropDownList({ 数据来源:任务, dataTextField:“显示标签”, dataValueField:“Id” }); jQuery(“#calendar”).fullCalendar({ 标题:{ 左:“上一个,下一个今天”, 中心:'标题', 对:“” }, 是的, 第一天:1, eventClick:函数(calEvent、jsEvent、view){ jQuery(“#itemId”).val(calEvent.id); jQuery(“#activityDate”).text(calEvent.start); jQuery(“#ddlMissions2”).data(“kendoDropDownList”).value(calEvent.missionId); jQuery(“#tbxDuration2”).val(calEvent.duration); jQuery(“#tbxComment2”).val(calEvent.comment); window.data(“kendoWindow”).open(); window.data(“kendoWindow”).center(); }, eventMouseover:函数(calEvent、jsEvent){ 变量工具提示=''+calEvent.title+'
'+calEvent.duration+'h
'+calEvent.comment+''; $(“正文”).append(工具提示); $(此).mouseover(函数(e){ $(this.css('z-index',10000); $('.tooltipevent').fadeIn('500'); $('tooltipevent').fadeTo('10',1.9); }).mousemove(函数(e){ $('.tooltipevent').css('top',e.pageY+10); $('.tooltipevent').css('left',e.pageX+20); }); }, eventMouseout:函数(calEvent、jsEvent){ $(this.css('z-index',8); $('.tooltipevent').remove(); }, eventRender:函数(事件,元素){ 元素.find('.fc event title').append(“
”+event.duration+“h”); 元素.find('.fc事件时间').hide(); }, dayRender:函数(日期、单元格){ cell.bind('dblclick',function(){ var ddlMissions=$(“#ddlMissions”).data(“kendoDropDownList”); var numDuration=$(“#tbxDuration”).data(“kendonumeric文本框”); 警报(“a”); userEvents.push({ id:userEvents[userEvents.length-1].id+1, 标题:ddl.text(), 任务ID:ddlMissions.value(), 开始:新日期(Date.getFullYear(),Date.getMonth(),Date.getDate()), 全天:错, 持续时间:numDuration.value(), 注释:jQuery(“#tbxComment”).val(), 颜色:“绿色” }); 警报(“b”); jQuery(“#calendar”).fullCalendar('refetchEvents'); 警报(“c”); }); }, 事件:userEvents }); jQuery(“btnModifyActivity”)。单击(函数(){ var currentId=jQuery(“#itemId”).val(); var activity=jQuery.grep(userEvents,函数(e){returne e.id==currentId;})[0]; activity.title=jQuery(“#ddlMissions2”).data(“kendoDropDownList”).text(); activity.missionId=jQuery(“#ddlMissions2”).data(“kendoDropDownList”).value(); activity.duration=jQuery(“#tbxDuration2”).val();
jQuery('#calendar').fullCalendar('removeEvents');
jQuery('#calendar').fullCalendar('addEventSource', userEvents);
$('#calendar').fullCalendar('rerenderEvents');
jQuery('#calendar').fullCalendar('refetchEvents');