Javascript FullCalendar dayClick js事件未分离

Javascript FullCalendar dayClick js事件未分离,javascript,jquery,fullcalendar,jquery-click-event,Javascript,Jquery,Fullcalendar,Jquery Click Event,我的网页上有一个完整的日历。日历上有许多事件。在day中,单击事件处理程序我正在调用一个函数 问题是第一次单击日框时,函数会被调用1次。第二次调用函数2次,第三次调用3次..依此类推 我可以猜到问题是day click事件没有分离。但我无法解决它 代码: $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'mont

我的网页上有一个完整的日历。日历上有许多事件。在
day中,单击事件处理程序我正在调用一个函数

问题是第一次单击日框时,函数会被调用1次。第二次调用函数2次,第三次调用3次..依此类推

我可以猜到问题是day click事件没有分离。但我无法解决它

代码:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    eventLimit: true,
    defaultView: 'month',
    editable: false,
    eventClick: function (event) {
        if (event.url) {
            window.open(baseUrl + event.url);
            return false;
        }
    },
    dayClick: function (date, allDay, jsEvent, view) {
        var dateString = '';
        dateString = moment(date, 'YYYY-MM-DD').format().split('T')[0];
        $('#popup').modal('toggle');
        $('#popup').on('shown.bs.modal', function () {
        AsyncFn().done(function (result) {
            AnotherAsyncFn(function () {
                SomeFunction();  //This function gets called multiple times                                           
                });
            });                   
        });                        
    }
}); 
我不知道如何分离此事件。可以使用
关闭
解除绑定
,但不知道具体操作方法。
有人能在这方面提供帮助吗?

您应该使用
off
方法

$('#popup').on('shown.bs.modal', function () {
    $('#popup').off('shown.bs.modal');
    AsyncFn().done(function (result) {
        AnotherAsyncFn(function () {
            SomeFunction();  //This function gets called multiple times                                           
        });
    });                   
});

再次附加事件之前,请尝试使用
jQuery.unbind()

dayClick: function (date, allDay, jsEvent, view) {
    var dateString = '';
    dateString = moment(date, 'YYYY-MM-DD').format().split('T')[0];
    $('#popup').modal('toggle');
    $('#popup').unbind("shown.bs.modal").on('shown.bs.modal', function () {
    AsyncFn().done(function (result) {
        AnotherAsyncFn(function () {
            SomeFunction();  //This function gets called multiple times                                           
            });
        });                   
    });                        
}