fullCalendar eventClick没有被解雇

时间:2016-03-15 07:20:14

标签: javascript jquery fullcalendar

我在应用中使用fullcalendar。我想通过单击单元格来更改单元格背景颜色,但eventClick未触发。 任何人都可以帮助我。 这里是代码:



 $(function () {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();


            $('#calendar').fullCalendar({
            
                eventClick: function (event) {
                    
                    alert('hello');
                    event.backgroundColor = 'yellow';
                    $(this).css('background-color', 'red');

                },
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'agendaWeek'
                },
                editable: true,
                defaultView: 'agendaWeek',
                slotMinutes:60
            });
        });




2 个答案:

答案 0 :(得分:0)

您可以使用dayClick事件。

$(function () {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();


            $('#calendar').fullCalendar({

                dayClick: function (date, jsEvent) { //Added this, use jsEvent for more customization
                     $(jsEvent.target).css('background-color', 'red');
                },
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'agendaWeek'
                },
                editable: true,  // Ensure you have this true
                disableResizing:true,   // Ensure you have this true
                defaultView: 'agendaWeek',
                slotMinutes:60
            });
        });

在点击日期,您可以自定义您的CSS。

答案 1 :(得分:0)

您需要调用UpdateEvent:

    $('#calendar').fullCalendar({
       eventClick: function(event, element) {    
           event.title = "CLICKED!";    
           $('#calendar').fullCalendar('updateEvent', event);    
       }
   });

消息来源:http://fullcalendar.io/docs/event_data/updateEvent/

相关问题