eventClick change background-color

旧巷老猫 提交于 2019-12-21 21:55:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!