Skip to content Skip to sidebar Skip to footer

Unable To Refetchevents When Updating Or Editing Events Using Ajax Modal. Fullcalendar

My problem is i'm unable to live edit the event after ajax success. Wnen i edit the event, the data will be updated in the database but it doesn't make any changes in the calendar

Solution 1:

The "RefetchEvents" method isn't doing anything because you have a static data source. You load it once when the page is created, and run some PHP which turns the event data into a JavaScript array and embeds it directly into your calendar config. From JavaScript/fullCalendar's point of view this is a one-off, unchanging array.

There's no way for fullCalendar to find new events from your server. For that to work you'd have to create a separate PHP script (e.g. called "getEvents.php" or something) which does nothing but return the latest event data for the calendar as JSON. Then you'd set the events option in the calendar as

events:"getEvents.php"

That way it can make a fresh ajax request to that script every time the events need updating (such as when refetchEvents is called).

See https://fullcalendar.io/docs/events-json-feed for details. note that fullCalendar automatically sends "start" and "end" parameters (which represent the earliest and latest dates the calendar is currently showing) and your PHP script is expected to only return events which fall between those dates. It will call this script again whenever you move to a new time period on the calendar.

Note that there is no need to call "removeEvent" just before you call "refetchEvents". "refetchEvents" will refresh any and all events on the calendar, so you don't need to worry about removing anything beforehand.

Post a Comment for "Unable To Refetchevents When Updating Or Editing Events Using Ajax Modal. Fullcalendar"