| Issue 1686: | Get IDs of multiple event sources all using same URL | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I have a calendar with multiple sources which all use the exact same url. The url points to a php script that will pull different data from a mysql db depending on the information that is passed to it. I would like to use checkboxes to show/hide different event sources. I know that I need to be using removeEventSource but I can only see how to remove the event source by url. I could use removeEvents to just remove the events from a source based on a piece of data in them but that will not work for what I am needing since I will need it to also add that data back to the calendar when the box is unchecked. Below is a sample of how I am getting my event sources. Is there any way to id them so that I can remove and add them?
eventSources:[
{
events: function(start, end, callback) {
$.getJSON( "php/json-events-master.php",
{ start: Math.round( Math.round( start.getTime() / 1000 ) ),
end: Math.round( Math.round( end.getTime() / 1000 ) ),
dept: "it",
cache: false
},
function( json ){
if ( json != null ) {
callback( json );
}
})
},
color: 'yellow',
textColor: 'black'
},
{
events: function(start, end, callback) {
$.getJSON( "php/json-events-master.php",
{ start: Math.round( Math.round( start.getTime() / 1000 ) ),
end: Math.round( Math.round( end.getTime() / 1000 ) ),
dept: "administration",
cache: false
},
function( json ){
if ( json != null ) {
callback( json );
}
})
},
color: 'red'
},
Thanks for the help!
Aug 21, 2013
(No comment was entered for this change.)
Status:
Done
|
|
| ► Sign in to add a comment |
Nevermind I figured it out. I made each event source a variable and used the addEventSource to add them when the page loads. Then I can just use that variable as the source in the removeEventSource or addEventSource that I trigger with the checkbox. I also had to change it to send information like color to the php script and have it sent back in the json array. I pasted the code below in case anyone else needs to do this. it = function(start, end, callback) { $.getJSON( "php/json-events-master.php", { start: Math.round( Math.round( start.getTime() / 1000 ) ), end: Math.round( Math.round( end.getTime() / 1000 ) ), dept: 'it', cache: false, color: 'yellow', textColor: 'black' }, function( json ){ if ( json != null ) { callback( json ); } }) }, $('#calendar').fullCalendar('addEventSource', it ); I placed this code below all of the fullcalendar stuff. Then to get the checkboxes to work I added this- $("#checks input.cb").mousedown(function() { var checkdept = $(this).val() if (!$(this).is(':checked')) { $('#calendar').fullCalendar('addEventSource', it); } else { $('#calendar').fullCalendar('removeEventSource', it) } }); And the input for my checkbox looks like this- <input class="cb" type="checkbox" value="it" id="cb1" checked>IT</input><br>