Javascript 通过$.Ajax绑定事件不会显示在日历上

Javascript 通过$.Ajax绑定事件不会显示在日历上,javascript,asp.net-mvc,fullcalendar,Javascript,Asp.net Mvc,Fullcalendar,我必须对现有的MVC应用程序进行维护,该应用程序使用的是我们所说的1.6.4版FullCalendar的旧版本。 作为最新的提交,视图通过模型传递数据作为视图的加载,因此以这种方式加载的事件: $('#divAgenda').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: '' },

我必须对现有的MVC应用程序进行维护,该应用程序使用的是我们所说的1.6.4版FullCalendar的旧版本。 作为最新的提交,视图通过模型传递数据作为视图的加载,因此以这种方式加载的事件:

  $('#divAgenda').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: ''
        },
        editable: false,
        disableDragging: true,
        events: eventsJson, 
        eventClick: function (calEvent, jsEvent, view) {
            eventDetail(calEvent.IdsEventi, calEvent.tipo, calEvent.start);
        },

function EventsJsonFunc() {
    var events = '<%= Html.Raw(Model.EventiJson) %>';

    return jQuery.parseJSON(events);
}
现在我已经在ComboBox事件更改时移动了加载,因为我必须过滤需要显示为的数据

var dropdownlist = $('#divAgendaFilter').kendoComboBox({
            dataTextField: "text",
            dataValueField: "value",
            dataSource: data,

            select: function (e) {
                if (e.item) {
                    var dataItem = this.dataItem(e.item.index());

                    $.ajax({
                        url: '<%= Url.Action("LoadData", "Agenda")%>',
                        type: "GET",
                        dataType: "json",
                        data: {
                            userId: '<%= Request.QueryString["userId"] == null ? string.Empty : Request.QueryString["userId"].ToString() %>',
                        selectedFilter: dataItem.value
                    },
                    success: function (data) {
                        var calendar = $('#divAgenda').data("fullCalendar");

                   //     var items = jQuery.parseJSON(data);
                        calendar.events=data;
                        debugger;

                    }
                });
            }

在数据中,我得到了事件,但在分配它们之后,什么都没有发生。。。我做错了什么?

calendar.events不会做任何事情,它不是日历的公共属性。阅读文档,它告诉您要公开哪些属性和方法。您需要使用RemoveEvents删除以前的事件数据,然后使用RenderEvents添加新版本。或者更好的方法是,首先使用动态事件数据源,然后当您想从服务器触发手动获取时,您可以调用refetchEvents,例如,由于您的组合框更改,但是调用RenderEvents将在第一次加载时加载数据,我想排除这一点。??你说的第一批货是什么意思?您可以在success函数中调用它,您现在可以在这里无用地编写calendar.events=data。这是做你现在所做事情的正确方法。请参阅,对于您的案例,请注意动态数据参数部分——或者,如果您需要更大的灵活性,请参阅我上面提到的内容。同样值得考虑升级到最新版本,它使其中一些任务变得更简单或具有更多选项。使用JSON或基于函数的数据馈送肯定会导致在首次创建日历时请求数据,是的……但是您可以将其设置为发送参数,以便服务器在从组合框中获取值之前不返回任何数据,或者您可以将其设置为某个默认值。有很多方法可以解决这个问题