I've installed Fullcalendar bundle (Symfony2) and all the events that I'm adding were showing correctly. Now I add eventClick
function in Fullcalendar.js (it works with open.window('page')
just for testing). Now I want to get all the information about this event (id,name,...etc) in an alert()
or something else instead of window.open()
.
How can I do that?
$(function () {
/* initialize the calendar
-----------------------------------------------------------------*/
//Date for the calendar events (dummy data)
var date = new Date();
var d = date.getDate(),
m = date.getMonth(),
y = date.getFullYear();
$('#calendar-place').fullCalendar({
monthNames: ["Janvier","Février","Mars","Avril","Mai","Juin","Julliet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre" ],
monthNamesShort: ['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec'],
dayNames: [ 'Diamnche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
dayNamesShort: ['Diu','Dill','Dim','Dix','Dij','Div','Dis'],
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
buttonText: {
today: 'today',
month: 'month',
week: 'week',
day: 'day'
},
events:
{
url:Routing.generate('fullcalendar_loadevents', { month: moment().format('MM'), year: moment().format('YYYY') }),
color: '#45b2ea',
textColor:'white',
error: function() {
alert('Error receving events');
}
},
viewRender: function (view, element) {
var month = view.calendar.getDate().format('MM');
var year = view.calendar.getDate().format('YYYY');
},
eventClick: function() {
window.open('login')
},
eventDrop: function(event,delta,revertFunc) {
var newStartData = event.start.format('YYYY-MM-DD');
var newEndData = (event.end == null) ? newStartData : event.end.format('YYYY-MM-DD');
$.ajax({
url: Routing.generate('fullcalendar_changedate'),
data: { id: event.id, newStartData: newStartData,newEndData:newEndData },
type: 'POST',
dataType: 'json',
success: function(response){
console.log('ok');
},
error: function(e){
revertFunc();
alert('Error processing your request: '+e.responseText);
}
});
},
eventResize: function(event, delta, revertFunc) {
var newData = event.end.format('YYYY-MM-DD');
$.ajax({
url: Routing.generate('fullcalendar_resizedate'),
data: { id: event.id, newDate: newData },
type: 'POST',
dataType: 'json',
success: function(response){
console.log('ok');
},
error: function(e){
revertFunc();
alert('Error processing your request: '+e.responseText);
}
});
},
editable: true
});
});