Reputation: 2530
I am fairly new to the FullCalendar, but totally love it's functionality.
I am trying to use the dayClick
function. Perhaps someone can guide me in the right direction.
I currently have this:
dayClick: function (date, allDay, jsEvent, view) {
var titleNew = prompt('Event Title:');
var thedate1 = formatDate(date);
$.ajax({
url: "classes/class.Post.php?a=dayClickCalendarEvent",
dataType: 'json',
data: {
title: titleNew,
start: thedate1,
end: thedate1
},
success: function (data, response, event, date) {
$('#calendar').fullCalendar('renderEvent', titleNew);
},
error: function () {
alert("Oops! Something didn't work");
}
});
},
My problem is that I can't get the event to RENDER to the calendar no matter what.
Am I missing something? I am using the calEvent
, where I found it on another Stack Overflow post.
Here is my format code:
function formatDate(date1) {
return date1.getFullYear() +'-'
+ (date1.getMonth() < 9 ? '0' : '')
+ (date1.getMonth()+1) +'-'
+ (date1.getDate() < 10 ? '0' : '')
+ date1.getDate() +' '
+ (date1.getHours() < 10 ? '0' : '')
+ date1.getHours() +':'
+ (date1.getMinutes() < 10 ? '0' : '')
+ date1.getMinutes();
}
Any help would be appreciated.
Upvotes: 2
Views: 4621
Reputation: 2530
Hey I thank you for your responses, I was able to use this code and it responds great!
dayClick: function (date, allDay, jsEvent, view) {
titleNew = prompt('Event Title:');
var thedate1 = formatDate(date);
$.ajax({
url: "classes/class.Post.php?a=dayClickCalendarEvent",
dataType: 'json',
data: {
title: titleNew,
start: thedate1,
end: thedate1
},
success: function (data, response, event, date) {
//alert("success here");
$('#calendar').fullCalendar('renderEvent',
{
title: titleNew,
start: thedate1,
end: thedate1
}, true);
},
error: function () {
alert("Oops! Something didn't work");
}
});
},
Upvotes: 1
Reputation: 1458
I think the problem is in this statement $('#calendar').fullCalendar('renderEvent', titleNew);
titleNew
is a string, and the renderEvent
function takes a calEvent object.
From the FullCalendar Documentation:
event must be an Event Object with a title and start at the very least. Normally, the event will disappear once the calendar refetches its event sources (example: when prev/next is clicked). However, specifying stick as true will cause the event to be permanently fixed to the calendar.
I'm curious why you are using an Ajax call though, it doesn't seem like you are doing anything with it.
Upvotes: 0