Javascript FullCalendar和JQuery事件

Javascript FullCalendar和JQuery事件,javascript,jquery,laravel,fullcalendar-4,Javascript,Jquery,Laravel,Fullcalendar 4,我在我的Laravel应用程序中制作了一个完整的日历。渲染正是我想要的:左侧是日历,当用户在某一天单击时,这一天变为“红色”,右侧是创建会议时间列表 在这里看到结果(我刚刚模糊了coach的名称;): 我在日历中使用以下代码创建列表: dateClick: function (info) { //Colorize the select day in red $('*').removeClass('activeday');

我在我的Laravel应用程序中制作了一个完整的日历。渲染正是我想要的:左侧是日历,当用户在某一天单击时,这一天变为“红色”,右侧是创建会议时间列表

在这里看到结果(我刚刚模糊了coach的名称;):

我在日历中使用以下代码创建列表:

dateClick: function (info) {
            //Colorize the select day in red
            $('*').removeClass('activeday');
            $('[data-date=' + info.dateStr + ']').addClass('activeday');

            // Ajax for recover all events 'Disponible"
            let qlq;
            $.ajax({
                url: 'events/get-disponibility',
                method: 'GET',
                dataType: 'json',
                async: false,
                data: {
                    date: info.dateStr,
                },
                error: function (request, status, error) {
                    console.log(request.responseText);
                    console.log(status);
                    console.log(error);
                },
                success: function (data) {
                    qlq = data;
                }
            });

            let html = "<h3>Horaires et Coachs disponibles : </h3> <br>";
            if (qlq.length) {
                qlq.forEach(function (row) {
                    html = html + '<div class="container d-flex mb-3">\
                    <div class="col-6">\
                    <span id="puce">&#8226;</span>\
                        ' + row.admin_prenom + ' ' + row.admin_nom + ' </div> \
                    <div class="col-6 justify-content-around">\
                        <span class="badge badge-pink">' + row.start_date.substring(11, 16) + '</span>\
                        <a href="#' + row.id + '" class="get-modal-event"\
                         data-idEvent=' + row.id + '>\
                        <span class="badge badge-dark">\
                        <i class="fas fa-arrow-right"></i>\
                        </span>\
                        </a>\
                    </div>\
                </div>';
                });

                $("#freeCoach").empty()
                    .append(html);
            } else {
                $("#freeCoach").empty()
                    .append('<div class="container d-flex mb-3">\
                    <div class="col-12">\
                    <span id="puce">&#8226;</span>\
                        Pas de coach disponible à cette date. <br>\
                        <br>\
                         Seul les dates comportant un fond coloré comporte des disponibilités</div> \
                </div>');
            }
        },
我已经创建了一个警报框,以查看该功能的工作情况,但没有警报显示,也没有模式显示

我试图在日历之外创建一个链接(使用的是自己的测试类),警报和模式都出现了

我还尝试将此代码放在不同的文件中并构建它,但结果是相同的

有什么想法吗?

您正在使用的
click()
绑定称为“直接”绑定,它只将处理程序附加到已经存在的元素。它不会被动态创建的元素绑定。您必须使用[
on()
]创建“委托”绑定

在这里,您需要使用:

$('body').on('click', 'a.get-modal-event', function(e) {
   e.preventDefault();
   alert('get modal !!!!!');
   $('#modal-event').modal('show');
});

谢谢你的帮助,但也不行。但是我不理解你的观点,直接绑定。@Malkom我认为你不需要在点击事件上面添加“每个”循环。只是用$('body')尝试了一下;我认为这应该行得通。
$('body').on('click', 'a.get-modal-event', function(e) {
   e.preventDefault();
   alert('get modal !!!!!');
   $('#modal-event').modal('show');
});