Javascript 如何从fullcalendar上的选择列表中为所选用户呈现事件

Javascript 如何从fullcalendar上的选择列表中为所选用户呈现事件,javascript,ajax,fullcalendar,fullcalendar-3,Javascript,Ajax,Fullcalendar,Fullcalendar 3,我只想渲染为特定用户分配的事件。在启动时,日志用户的fullcalendar呈现事件将正常工作。此外,我使用selectlist将choosen用户ID发送到控制器。作为响应,我得到json和所选用户的所有事件 我已尝试使用“eventSources”,但当我尝试使用所选事件调用函数时,无法使用“callback”控制台中的错误原因:Uncaught TypeError:callback不是Object.success中的函数 我做了以下工作: 完整日历初始化 $('#calendar').

我只想渲染为特定用户分配的事件。在启动时,日志用户的fullcalendar呈现事件将正常工作。此外,我使用selectlist将choosen用户ID发送到控制器。作为响应,我得到json和所选用户的所有事件

我已尝试使用“eventSources”,但当我尝试使用所选事件调用函数时,无法使用“callback”控制台中的错误原因:Uncaught TypeError:callback不是Object.success中的函数

我做了以下工作:

完整日历初始化

  $('#calendar').fullCalendar({
        defaultView: 'agendaWeek',
        height: 700,
        header: {
            left: 'agendaDay,agendaWeek,month',
            right: 'none'
        },
        eventRender(event, $el) {
            $el.qtip({
                content: {
                    title: event.title,
                },
                hide: {
                    event: 'unfocus'
                },
                show: {
                    solo: true
                },
                position: {
                    my: 'top left',
                    at: 'bottom left',
                    viewport: $('#calendar-wrapper'),
                    adjust: {
                        method: 'shift'
                    }
                }
            });
        },
       eventSources: [
          getEvents,
          getAnotherUserEvents
        ],

    });
具有已记录用户事件的函数:

function getEvents(start, end, timezone, callback) {
    const apiUrl = "https://localhost:44308/event/";
    $.ajax({
        url: apiUrl + '/getevents',
        type: 'GET',
        dataType: 'json',
        success: function (doc) {
            var events = [];
            if (doc != undefined && doc.length > 0) {
                doc.forEach(function (entry) {
                    entry.destinationTimeViewModel.forEach(function (dt) {
                        events.push({
                            title: dt.subject,
                            description: dt.description,
                            start: dt.startedAt,
                            end: dt.endedAt
                        });
                    });
                    events.push({
                        title: entry.subject,
                        description: entry.description,
                        start: entry.startedAt,
                        end: entry.endedAt,
                        color: entry.color,
                        user: entry.users,
                        id: entry.id
                    });
                });
            }
            callback(events);

        },
    });
};
具有所选用户数据的事件的函数包含所选用户Id

function getAnotherUserEvents(start, end, timezone, callback, data) {
    const apiUrl = "https://localhost:44308/event/";
    $.ajax({
        type: 'POST',
        url: apiUrl + '/GetAnotherUserEvents',
        dataType: 'json',
        data: {
            "Id": data.id,
        },
        success: function (doc) {
            var events = [];
            if (doc != undefined && doc.length > 0) {
                doc.forEach(function (entry) {
                    entry.destinationTimeViewModel.forEach(function (dt) {
                        events.push({
                            title: dt.subject,
                            description: dt.description,
                            start: dt.startedAt,
                            end: dt.endedAt
                        });
                    });
                    events.push({
                        title: entry.subject,
                        description: entry.description,
                        start: entry.startedAt,
                        end: entry.endedAt,
                    });
                });
            }
            callback(events);
        },
    })
}

您知道如何仅显示所选用户的事件吗?

哪一行准确地抛出了错误?是getEvents中的callbackevents还是getAnotherUserEvents中的同一行?另外,我不知道getAnotherUserEvents中的数据变量是从哪里来的开始、结束、时区、回调、数据?fullCalendar在执行回调时如何知道提供那个额外的参数?它不能也不会知道这一点。无论数据中应该包含什么,您都需要以另一种方式获取它。我想它应该来自你选择列表中的值??如果是这样,您可以直接从选择列表中获取值,例如$myselectlist.val