Grazie per questo esempio :)
non ero in grado di fare questo (nel codice sopra la matrice eventi) lavoro per me, ma ho dato un altro modo per aggiungere sorgenti di eventi utilizzando parte del codice che si fornito.
Questa è la mia logica:
La mia fonte primaria degli eventi è questo (questa è la fonte eventi dagli esempi di default del Fullcalendar):
events: function(start, end, callback) {
$.ajax({
type: 'POST',
url: 'myurl',
dataType:'xml',
crossDomain: true,
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime()/1000),
end: Math.round(end.getTime()/1000),
'acc':'2',
},
success: function(doc) {
var events = [];
var allday = null; //Workaround
var Editable = null; //Workaround
$(doc).find('event').each(function()
{
if($(this).attr('allDay') == "false") //Workaround
allday = false; //Workaround
if($(this).attr('allDay') == "true") //Workaround
allday = true; //Workaround
if($(this).attr('editable') == "false") //Workaround
Editable = false; //Workaround
if($(this).attr('editable') == "true") //Workaround
Editable = true; //Workaround
events.push({
id: $(this).attr('id'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
allDay: allday,
editable: Editable
});
});
//calendar.fullCalendar('addEventSource', othersources.folgas);
//calendar.fullCalendar('addEventSource', othersources.ferias);
//calendar.fullCalendar('refetchEvents');
callback(events);
}
});
}
Ora avevo bisogno di aggiungere più fonti e per fare questo ouside il calendario (accanto alle variabili data da esempi fullcalendar) ho fatto una variabile come il codice di cui sopra, ma con l'Ajax chiamate simile al mio primario:)
var othersources = {
anothersource: {
events: function(start, end, callback) {
$.ajax({
type: 'POST',
url: 'myurl',
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime()/1000),
end: Math.round(end.getTime()/1000),
'acc':'7',
},
success: function(doc) {
var events = [];
var allday = null; //Workaround
var Editable = null; //Workaround
$(doc).find('event').each(function()
{
if($(this).attr('allDay') == "false") //Workaround
allday = false; //Workaround
if($(this).attr('allDay') == "true") //Workaround
allday = true; //Workaround
if($(this).attr('editable') == "false") //Workaround
Editable = false; //Workaround
if($(this).attr('editable') == "true") //Workaround
Editable = true; //Workaround
events.push({
id: $(this).attr('id'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
allDay: allday,
editable: Editable
});
});
callback(events); //notice this
}
});
},
cache: true,
//error: function() { alert('something broke with courses...'); },
color: 'green', //events color and stuff
textColor: 'white',
//className: 'course'
}
}
Il seguente codice è simile al precedente e fa parte delle proprietys calendario (all'interno variabile calendario):
eventSources: [ othersources.anothersource ],
viewDisplay: function(view) {
if (view.name == 'month'){
// alert(view.name);
//calendar.fullCalendar('addEventSource', othersources.folgas);
calendar.fullCalendar('addEventSource', othersources.anothersource);
//calendar.fullCalendar('refetchEvents'); //Notice i'm not doing the refetch events. And its working for me. but i'm calling thi elsewhere, every time i make an action. So you must figure it out ;)
}
grazie per la risposta. Con il tuo codice sono riuscito a trovare il seguente: $ ("# TaskSelector"). Change (onSelectChange); \t funzione onSelectChange() { \t \t $ ('# calendario') fullCalendar ('removeEventSource', radice + '/ eventi /' + defaultFeed) .fullCalendar ('refetchEvents.'); \t \t defaultFeed = $ ('# TaskSelector'). Val(); \t \t $ ('# calendar'). FullCalendar ('addEventSource', root + '/ events /' + defaultFeed) .fullCalendar ('refetchEvents'); \t} }); Funziona bene, ma potresti vedere qualche problema con esso? Ho impostato defaultFeed nella parte superiore del codice, e finora tutto bene. Grazie per la tua risposta! – Kingsley
@RET http://stackoverflow.com/questions/37204410/how-to-show-event-details-on-click-of-day-in-full-calendar puoi verificare questa domanda? –