无法在日历中显示事件

I use https://github.com/tattali/CalendarBundle#1-download-calendarbundle-using-composer I work with symfony4.2.9

I took almost the same code(just putted dates in the events) and I can't see the events in the calendar. No error, no troubleshooting with Ajax, but nothing append. The calendar is displayed but empty

namespace App\EventListener;
use CalendarBundle\Entity\Event;
use CalendarBundle\Event\CalendarEvent;

class CalendarListener
{
  public function load(CalendarEvent $calendar)
  {
    $start = $calendar->getStart();
    $end = $calendar->getEnd();
    $filters = $calendar->getFilters();

    // You may want to make a custom query to fill the calendar

    $calendar->addEvent(new Event(
        'Event 1',
        new \DateTime( '2019-06-05'),
        new \DateTime( '2019-06-05')
    ));

    // If the end date is null or not defined, it creates a all day event
    $calendar->addEvent(new Event(
        'All day event',
        new \DateTime( '2019-06-06')
    ));
  }
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Welcome!</title>
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
        <link rel="stylesheet" href="/css/bootstrap.min.css">
        <link rel="stylesheet" href="/css/app.css">

            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fullcalendar/core@4.1.0/main.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@4.1.0/main.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fullcalendar/timegrid@4.1.0/main.min.css">

        <script src="/js/jquery.min.js"></script>

    </head>
<body>
<nav class="navbar navbar-expand-lg  bg-">
            <a class="navbar-brand" href="/">Share</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarColor01">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item active">
                        <a class="nav-link" href="/account/dashboard"><i class="fas fa-chart-line fa-2x"></i>  Tableau de bord</a>
                    </li>
                    <li class="nav-item ">
                        <a class="nav-link" href="/dashboard/showMines"><i class="fas fa-hands-helping fa-2x"></i>  offres d'atelier <span class="badge-pill badge-danger dash">3</span> </a>
                    </li>
                    <li class="nav-item ">
                        <a class="nav-link" href="/dashbord/books"><i class="fas fa-graduation-cap fa-2x "></i>  cours pris<span class="badge-pill badge-danger dash">2</span></a>
                    </li>
                    <li class="nav-item ">
                        <a class="nav-link" href="/dashboard/courses"><i class="fas fa-chalkboard-teacher fa-2x"></i>  cours donnés</a>
                    </li>
                     <li class="nav-item ">
                        <a class="nav-link" href="/dashboard/calendar"><i class="fas fa-calendar-alt fa-2x"></i>  mon agenda</a>
                    </li>

                </ul>

                <ul class="navbar-nav ml-auto align-items-center">
                                <li class="nev-item">
                    <a href="/" class="nav-link" ><i class="fas fa-home fa-2x"></i></i>  Retour à l'accueil</a>
                </li>
                <li class="nav-item dropdown">

                    <a href="#" class="nav-link dropdown-toggle" id="accountDropdownlink" data-toggle="dropdown">
                        <img src="https://randomuser.me/api/portraits/women/56.jpg" alt="Avatar de Cécile" class="avatar avatar-small" class="mr-2"><span class="ml-2 mt-5">Cécile</span>
                    </a>

                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="accountDropdownlink">
                    <a class="dropdown-item" href="/activity/new">Créer une activité</a>
                        <div class="dropdown-divider"></div>

                        <a class="dropdown-item" href="/account">Mon compte</a>

                  <a class="dropdown-item" href="/account/edit">Modifier mon profil</a>
                        <div class="dropdown-divider"></div>

                        <a class="dropdown-item" href="/logout">Déconnexion</a>

                </div>

                </li>    



                </ul>

            </div>
        </nav></div>



<div class="container mt-5">
    <div id="calendar-holder"></div>
</div>    


<footer class="bg-warning text-center py-3 mt-3">


</footer>

<script src="/js/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


    <script>

    document.addEventListener('DOMContentLoaded', () => {

    var calendarEl = document.getElementById('calendar-holder');

    var calendar = new FullCalendar.Calendar(calendarEl, {
        //locale: 'fr',
        defaultView: 'dayGridMonth',
        editable: true,
        eventSources: [
            {
                url: "/fc-load-events",
                method: "POST",
                extraParams: {
                  //  filters: JSON.stringify({})
                },
                failure: () => {
                     alert("There was an error while fetching FullCalendar!");
                },
            },
        ],
        header: {
            locale:'fr',
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth,timeGridWeek,timeGridDay',
        },
        plugins: [ 'interaction', 'dayGrid', 'timeGrid' ], // https://fullcalendar.io/docs/plugin-index
        timeZone: 'Europe/Paris',
    });
   calendar.setOption('locale', 'fr');

    calendar.render();



});

    </script>

    <script src="https://cdn.jsdelivr.net/npm/@fullcalendar/core@4.1.0/main.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@fullcalendar/interaction@4.1.0/main.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@4.1.0/main.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@fullcalendar/timegrid@4.1.0/main.min.js"></script>


I expect to see my events :), if someone has an idea about what's wrong

douzhan1963
douzhan1963 好的,谢谢你的帮助ADyson:)
一年多之前 回复
dtyz76562
dtyz76562 这不会导致它只返回一个空数组。如果您使用无效的日期格式,我希望它会生成异常或类似内容。无论如何,这个简单的演示证明你如何写日期没有错。序列化过程更有可能出错或以某种方式发生。您将需要更深入地调试PHP。
一年多之前 回复
douyue1998
douyue1998 塞尔帕,你的意思是文件routes.yaml?
一年多之前 回复
dongmo9996
dongmo9996 响应ijson[]。也许日期格式有问题?
一年多之前 回复
doucuo1642
doucuo1642 还要在路由器文件上检查此路由/fc-load-events...
一年多之前 回复
dousi1906
dousi1906 在您的情况下,单击网络选项卡中的/fc-load-eventsURL,然后单击Response选项卡。如果它工作正常,我希望看到类似[{“title”:“Event1”,“start”:“2019-06-05”,“end”:“2019-06-05”},{“标题”:响应正文中的“全天事件”,“开始”:“2019-06-06”}]
一年多之前 回复
duandang6352
duandang6352 在你提出的问题中,你说AJAX没有问题。但是没问题。你到底有什么麻烦?你已经告诉我发送了什么请求,但我想知道的是收到了什么回复?您是否了解如何在浏览器的网络工具中查找?例如这会向您显示使用Chrome在哪里找到它:developers.google.com/web/tools/chrome-devtools/network/...
一年多之前 回复
douba9425
douba9425 它只是日历开始和结束的日期。我试图加载没有过滤器的日历,但仍然没有附加
一年多之前 回复
dongyejun1983
dongyejun1983 我有ajax的士兵,请求是:start=2019-05-26T00%3A00%3A00&end=2019-07-07T00%3A00%3A00&timeZone=Europe%2FParis
一年多之前 回复
dongpeng8994
dongpeng8994 你提到你对AJAX进行了故障排除,那么fc-events网址的原始响应究竟是什么呢?需要有一系列JSON格式的有效事件。我当然不熟悉symfony,但我不清楚所显示的PHP代码本身会如何产生这样的响应。$calendar对象在某些时候变成了JSON吗?
一年多之前 回复
duanpuchun5275
duanpuchun5275 完成后,我希望这就是你所需要的
一年多之前 回复
duanliaouu965826
duanliaouu965826 您能否发布由此PHP生成的JavaScript和HTML代码?
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐