我已经安装了Fullcalendar软件包(Symfony2),我正在添加的所有事件都正确显示。现在我在Fullcalendar.js中添加eventClick
函数(它与open.window('page')
一起用于测试)。现在,我希望在alert()
或其他内容而不是window.open()
中获取有关此活动的所有信息(ID,名称等)。
我该怎么做?
$(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
});
});
答案 0 :(得分:0)
如果您在https://fullcalendar.io/docs/mouse/eventClick/阅读了eventClick的文档,它会向您显示回调可用的参数,其中包含"事件"包含所点击事件详情的对象。
所以你可以这样做:
eventClick: function( event, jsEvent, view )
{
alert(event.title);
}
您可以在此处找到事件对象的更多属性:https://fullcalendar.io/docs/event_data/Event_Object/,以防您想要使用有关该事件的其他信息。