0

After 3hours of searching, I couldn't find the answer to my problem.

I've created a fullcalendar V3 an now i'm updating to V5. I thought it will be easy but, no, its not easy at all for my actual level. (i've started to code at 4 months, i'm a really rookie).

So, the code that works:

<head>
  <script>
        $(document).ready(function() {

            var calendar = $('#calendar').fullCalendar({
                locale: 'fr',
                defaultView: 'listWeek',
                editable: true,
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay,listWeek'
                },
                events: 'load.php',
                eventColor: 'red',
                selectable: true,
                selectHelper: true,

                //try to make data request from input
                //see documents in Montauban/Calendar and try to modify this lignes

                select: function(start, end, allDay) {
                    var title = prompt("Entrez l'evenement");
                    if (title) {
                        var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
                        var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
                        $.ajax({
                            url: "insert.php",
                            type: "POST",
                            data: {
                                title: title,
                                start: start,
                                end: end
                            },
                            success: function() {
                                calendar.fullCalendar('refetchEvents');
                                alert("Evenement créé avec succès");
                            }
                        })
                    }
                },
                editable: true,
                eventResize: function(event) {
                    var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
                    var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
                    var title = event.title;
                    var id = event.id;
                    $.ajax({
                        url: "update.php",
                        type: "POST",
                        data: {
                            title: title,
                            start: start,
                            end: end,
                            id: id
                        },
                        success: function() {
                            calendar.fullCalendar('refetchEvents');
                            alert('Evenement mis a jour');
                        }
                    })
                },

                eventDrop: function(event) {
                    var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
                    var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
                    var title = event.title;
                    var id = event.id;
                    $.ajax({
                        url: "update.php",
                        type: "POST",
                        data: {
                            title: title,
                            start: start,
                            end: end,
                            id: id
                        },
                        success: function() {
                            calendar.fullCalendar('refetchEvents');
                            alert("Evenement mis a jour");
                        }
                    });
                },

                eventClick: function(event) {
                    if (confirm("Êtes-sur sûr de vouloir supprimer?")) {
                        var id = event.id;
                        $.ajax({
                            url: "delete.php",
                            type: "POST",
                            data: {
                                id: id
                            },
                            success: function() {
                                calendar.fullCalendar('refetchEvents');
                                alert("Evenement supprimé");
                            }
                        })
                    }
                },

            });
        });
    </script>
</head>

And the code that do not work with the follows errors:

Uncaught TypeError: Cannot read property 'nodeName' of null

Uncaught TypeError: calendar.FullCalendar is not a function at Object.success ((index):106) at c (jquery.min.js:2)at Object.fireWith [as resolveWith] (jquery.min.js:2)at l (jquery.min.js:2)at XMLHttpRequest. (jquery.min.js:2)

<head>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
         
            var calendarEl = document.getElementById('calendar');
            var calendar = new FullCalendar.Calendar(calendarEl, {
                initialView: 'dayGridMonth',
                locale: 'fr',
                editable: true,
                themeSystem: 'bootstrap',
                headerToolbar: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
                },
                events: 'load.php',
                eventColor: 'red',
                selectable: true,
                editable: true,
                eventResize: function(event) {
                    var start = FullCalendar.formatDate(event.start, {
                        month: "long",
                        year: "numeric",
                        day: 'numeric',
                        locale: 'fr',

                    });
                    var end = FullCalendar.formatDate(event.end, {
                        month: "long",
                        year: "numeric",
                        day: 'numeric',
                        locale: 'fr',

                    });
                    var title = event.title;
                    var id = event.id;
                    console.log('hey')
                    $.ajax({
                        url: "update.php",
                        type: "POST",
                        data: {
                            title: title,
                            start: start,
                            end: end,
                            id: id
                        },
                        success: function() {
                            calendar.FullCalendar('refetchEvents');
                            alert('Evenement mis a jour');
                        }
                    })
                },
                eventDrop: function(event) {
                    var start = FullCalendar.formatDate(event.start, {
                        month: "long",
                        year: "numeric",
                        day: 'numeric',
                        locale: 'fr',

                    });
                    var end = FullCalendar.formatDate(event.end, {
                        month: "long",
                        year: "numeric",
                        day: 'numeric',
                        locale: 'fr',

                    });
                    var title = event.title;
                    var id = event.id;
                    $.ajax({
                        url: "update.php",
                        type: "POST",
                        data: {
                            title: title,
                            start: start,
                            end: end,
                            id: id
                        },
                        success: function() {
                            calendar.FullCalendar('refetchEvents');
                            alert("Evenement mis a jour");
                        }
                    });
                },
                eventClick: function(event) {
                    if (confirm("Êtes-sur sûr de vouloir supprimer?")) {
                        var id = event.id;
                        $.ajax({
                            url: "delete.php",
                            type: "POST",
                            data: {
                                id: id
                            },
                            success: function() {
                                calendar.FullCalendar('refetchEvents');
                                alert("Evenement supprimé");
                            }
                        })
                    }
                },
            });
            calendar.render();
        });
    </script>
</head>

In the first example (fulcalendar V3) everything works and the database its update when we "drop events, delete events". In the second example (fullcalendar V5), we can click and drop in the events, but the data base its not updated with the new info.

Can you please try to help me?

Sorry for my bad English. :)

jr23
  • 45
  • 10
  • possible duplicate of [Uncaught TypeError: Cannot read property 'nodeName' of undefined](https://stackoverflow.com/questions/9362583/uncaught-typeerror-cannot-read-property-nodename-of-undefined) – Mekel Ilyasa Feb 12 '21 at 18:00
  • Looks like the error is coming from somewhere deep in jquery. Have you set breakpoints to debug and see where it specifically fails? – mwilson Feb 12 '21 at 18:18
  • `calendar.FullCalendar('refetchEvents');` should be `calendar.refetchEvents();` in V5. Check the documentation, it already shows you: https://fullcalendar.io/docs/Calendar-refetchEvents – ADyson Feb 12 '21 at 22:04
  • The parameter coming into eventResize has also changed. again it shows you in the documentation. Look carefully: https://fullcalendar.io/docs/eventResize – ADyson Feb 12 '21 at 22:06
  • Same for eventDrop and eventClick, they have changed too. Check the documentation for those, as well. Compare them to the V3 documentation. If you still don't understand, ask again and explain your specific difficulty – ADyson Feb 12 '21 at 22:07
  • Please add your html here – Paras Raiyani Feb 13 '21 at 06:59
  • @parasraiyani html isn't relevant here. The above code generates some complex HTML for displaying a calendar. The errors are in the code. – ADyson Feb 13 '21 at 08:05
  • how put fullcalendar js and jquery this is relevent here.. – Paras Raiyani Feb 13 '21 at 08:10
  • @parasraiyani not sure what you mean, sorry. But there is not HTML the OP could show which would make any difference to the question. In my earlier comments I've already told them what their problems are. – ADyson Feb 13 '21 at 08:25
  • @ADyson. Thanks. You was right. :) – jr23 May 24 '21 at 22:32

0 Answers0