I am using FullCallendar and Jquery. I made a google calendar like interface and pull events from a json file. When a user clicks on a day a div opens for them to enter info click add event and the event is added. On the second click when the user clicks add event two events are added, one on the first clicked day and the second on the selected day. On the third click 3 events are added and so on. Here is the code: var c = 0;
function cleanEventBubble(){
$('#event').hide();
$('td').removeClass('selDay');
$('#eventDate').text('');
$('#calEvent,input:text').val('');
}
function createEvent(date, allDay, jsEvent, View, selCell){
//Clean the event bubble and calendar
cleanEventBubble();
$(selCell).addClass('selDay');
$('#eventDate').append(date.toDateString());
$('#event').css('left', jsEvent.pageX);
$('#event').css('top', jsEvent.pageY);
$('#event').show();
$('#btnAddEvent').click(function(){addEvent(date, $('#title').val(), c)});
}
function addEvent(date, title, id){
$.ajax({
type:'get',
<cfoutput>url: '#strURL#'</cfoutput>,
data:{
method:'addEvent',
user:1,
title:title,
allDay:'true',
start:$.fullCalendar.formatDate( date, 'yyyy-MM-dd' )
},
dataType: 'json',
success: function(data, status){alert('response: ' + data);},
error: function(data){$('#returnMess').html(data);}
});
$('#calendar').fullCalendar( 'refetchEvents' )
cleanEventBubble();
}
/**/
function removeEvent(id){
$('#calendar').fullCalendar('removeEvents', id);
}
function updateEvent(id, title){
var event = $('#calendar').fullCalendar('clientEvents', id);
event.title = title;
$('#calendar').fullCalendar('updateEvent', event);
}
$(document).ready(function() {
//Create JQuery connection to obj
$('#event').hide();
//Make event bubble draggable
$('#event').draggable();
$('#evBubbleClose').click(cleanEventBubble);
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here date, allDay, jsEvent, view
dayClick:function(date, allDay, jsEvent, view){
createEvent(date, allDay, jsEvent, view, this);
},
<cfoutput>events: '#strURL#'+'?wsdl&method=getEvents'</cfoutput> ,
theme: true,
header: {left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' },
editable:true
});
//$('#calendar').fullCalendar('renderEvents');
});