Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery fullcalendar send custom parameter and refresh calendar with JSON

I'm trying to use the jQuery fullcalendar. The event data comes from the server using JSON. My page has a dropdown element and the fullcalendar div.

What I need is to refresh the calendar each time the user changes the dropdown. The selected value of the dropdown should be posted to the server in order to fetch the new event data.

Here is my code:

     $(document).ready(function() {         $('#calendar').fullCalendar({             events: {                 url : '/myfeed',                 data : {personId : $('#personDropDown').val() }             }         });          $('#personDropDown').change(function(){             $('#calendar').fullCalendar('refetchEvents');         });      }); 

However, the code above doesn't work. Any help?

like image 417
user711189 Avatar asked Mar 21 '12 08:03

user711189


Video Answer


1 Answers

try this:

$(document).ready(function () {     $('#calendar').fullCalendar({         events: {             url: '/myfeed',             data: function () { // a function that returns an object                 return {                     personId: $('#personDropDown').val(),                 };              }         });       $('#personDropDown').change(function () {         $('#calendar').fullCalendar('refetchEvents');     });  }); 
like image 151
Jairo Cordero Avatar answered Sep 20 '22 18:09

Jairo Cordero