I'm making a calednar where people can click and book the diffrent days.
The event data that are added to the calendar looks like this:
var myEvent = {
user_id: 2345,
title: 'this is a title',
allDay: true,
start: date.format(),
end: date.format()
};
When its added i want to check if the user_id exist so user dont add event again.
I'm using the dayClick
event and the code looks like this:
dayClick: function(date, jsEvent, view) {
var myEvent = {
user_id: userid,
title: title,
allDay: true,
start: date.format(),
end: date.format()
};
var allEvents = allEvents = $('.calendar').fullCalendar('clientEvents');
$.each( allEvents, function( index, value ){
//add event if not exist
if(value.user_id != userid){
$('.calendar').fullCalendar( 'renderEvent', myEvent );
}
});
}
It seams that the event are added even tho the value is added. Is there a better/easyer way to do this?