问题
I am trying to change the "event" background-color
when I click the event in FullCalendar
I am trying the following -
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "json-events.php",
eventDrop: function(event, delta) {
alert(event.id);
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
eventClick: function(event){
$(event.target).css('background-color','yellow');
}
});
});
This however does nothing. Can this be done and can someone point me in the right direction?
Thanks
回答1:
eventClick: function(event) {
event.backgroundColor = 'yellow';
$('#mycalendar').fullCalendar( 'rerenderEvents' );
},
回答2:
eventClick
passes an FC event object, not a jQuery event. You can change the calendar event's properties, and then just updateEvent.
回答3:
Your function callback doesn't have the scope to use $(this)
- that's why it's passed the jQuery Event object.
You should use event.target - this is the DOM element which initiated the event.
回答4:
eventClick: function(event){
$(this).css('background-color','yellow');
}
来源:https://stackoverflow.com/questions/14657414/eventclick-change-background-color