Symfony 和 Fullcalendar 如何在文本已有 html 标签的情况下如何将文本插入日历标题

问题描述 投票:0回答:1

我的数据库中有一些有关大学日程的信息。类的描述与html标签一起存储在数据库中。我想显示这个时间表,但不删除标签,也不将它们显示为文本,而是显示为页面结构。

我的树枝文件中的脚本:


        <script src='https://cdn.jsdelivr.net/npm/[email protected]/index.global.min.js'></script>
        <script>

            document.addEventListener('DOMContentLoaded', function() {
                var calendarEl = document.getElementById('calendar');
                var calendar = new FullCalendar.Calendar(calendarEl, {
                    initialView: 'listWeek',
                    events: {{ data|raw }}
                });
                calendar.render();
            });

        </script>
    public function getScheduleFromCalendar(LessonRepository $lessonRepository)
    {
        $groupSchedule = $lessonRepository->findGroupLessons('КН-1-4М');
        $lessonsList = [];
        foreach ($groupSchedule as $lesson) {
            if ($lesson->getLessonContent()) {
                $lessonsList[] = [
                    'start' => $lesson->getLessonStart()->format('Y-m-d H:i:s'),
                    'end' => $lesson->getLessonEnd()->format('Y-m-d H:i:s'),
                    'title' => $lesson->getLessonContent(),
                ];
            }
        }
        $data = json_encode($lessonsList);

        return $this->render('schedule/index.html.twig', compact('data'));
    }

我该如何解决?谢谢大家!

javascript php symfony fullcalendar fullcalendar-6
1个回答
0
投票
    <script>

        document.addEventListener('DOMContentLoaded', function() {
            var calendarEl = document.getElementById('calendar');
            var calendar = new FullCalendar.Calendar(calendarEl, {
                initialView: 'listWeek',
                events: {{ data|raw }},
                eventContent: function(info) {
                    return {
                        html: info.event.extendedProps.content
                    };
                }

            });
            calendar.render();
        });

    </script>
© www.soinside.com 2019 - 2024. All rights reserved.