javascript - fullCalendar 事件Click 未触发

标签 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
            });
        });

最佳答案

您可以使用 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。

关于javascript - fullCalendar 事件Click 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004835/

相关文章:

Javascript 函数在 if 语句中应该为 true 时返回 false?

javascript - require ('react-native' ).NativeModules 是一个空对象

javascript - 这个 javascript "translate"如何转换为 CoffeeScript?

javascript 使用 echo 监听多个套接字 channel

javascript - 获取表格行的值并将它们打印在另一个 div 中

jquery - 带有可导出日历的 Rails 3 应用程序

javascript - 更改周历中的时间间隔

jquery - jQuery UI 中的 disableSelection 有什么用?

jquery - 延迟加载插件 (jQuery)

jquery - fullcalendar 将列更改为行