I use the FullCalendar plugin on my site to display calendar events. What I'm trying to add now is a drop-down menu with a name, and if the drop-down menu changes the value, then restart the events based on the value of the menu.
If there are other words, by default I load events that belong to me. The dropdown menu will have all users in one menu. From this menu I can change the username to view other user events on one page.
I tried adding the .change () event to the drop-down menu and refetchEvents on fullCalendar, but it does not work.
Can someone please help me with reloading these events by passing the value $ ('# users_menu').
Below is my current code
$(document).ready(function() { $('#calendar').fullCalendar({ header: { right: 'prev,next today', center: 'title', left: 'month,agendaWeek,agendaDay' }, events: { url: "ajax/getMyEvents.php", type: 'POST', data: { user_id: $('#users_menu').val() } }, timeFormat: 'h:mm TT{ - h:mm} TT', defaultView: 'agendaDay', eventDrop: function(event, delta, minuteDelta, allDay, revertFunc) { if (!confirm("Are you sure about this change?")) { revertFunc(); } updateEvent(event, delta, minuteDelta, allDay, 'Drop', revertFunc); }, eventResize: function(event, delta, minuteDelta, revertFunc) { if (!confirm("Are you sure about this change?")) { revertFunc(); } updateEvent(event, delta, minuteDelta, false, 'endResize', revertFunc); } }); $('#users_menu').change( function(){ $('#calendar').fullCalendar( 'refetchEvents' ); }); });
Please note that I pass my user_id value in my data method.
This code works with a load, but when I change the username in the drop-down menu, it does not reload new events.
How can I make this work?