2012-06-16 14 views
5

Ho problemi ad aggiungere un nuovo evento a fullCalendar usando Jquery. Sto usando Eclipse per sviluppare web e non ho familiarità con Ajax affatto e aperantly, non funziona con la mia eclissi.Inserisci evento dinamicamente su Fullcalendar usando Jquery

Tutto è scritto all'interno di una funzione button.click in jquery.

var subject = $("#txtEventName").val(); //the title of the event   
var dateStart = $("#txtDate").val();  //the day the event takes place 
var dateEnd = $("#txtDateEnd").val(); //the day the event finishes 
var allDay = $("#alldayCheckbox").val(); //true: event all day, False:event from time to time   

var events=new Array();  
event = new Object();  
event.title = subject; 
event.start = dateStart; // its a date string 
event.end = dateEnd;  // its a date string. 
event.color = "blue"; 
event.allDay = false; 

events.push(event); 
$('#calendar').fullCalendar('addEventSource',events); 

Nessun errore rilevato ma l'evento non è stato creato. P.S: Vorrei rimanere con il feed di array se non altro in jQuery.

+0

"evento" è una parola di riserva in Javascript, quindi modificare il nome dell'oggetto "evento" nel codice, potrebbe funzionare. –

+0

@Furqan l'ho fatto, non funziona ancora :( –

+0

Quali file .js hai incluso nel tuo codice HTML? – ganeshk

risposta

11

Prova questa:

var newEvent = new Object(); 

newEvent.title = "some text"; 
newEvent.start = new Date(); 
newEvent.allDay = false; 
$('#calendar').fullCalendar('renderEvent', newEvent); 

Si noti che quando si assegna il valore di start ha bisogno di essere in uno dei formati supportati.

È possibile specificare una stringa in formato IETF (es: "Mer, 18 Ott 2009 13:00:00 EST"), una stringa in formato ISO8601 (ad esempio: "2009-11-05T13: 15: 30Z") o un timestamp UNIX.