jQuery完整日历事件标题时间错误

时间:2014-11-16 14:30:02

标签: javascript jquery fullcalendar

我的UI中有一个jQuery Full Calendar,它看起来如下:

enter image description here

问题是事件标题的10:00-10:00部分,它似乎是根据设置UI元素的JSON中的事件startTime和endTime参数添加到元素中的。请在此处查看我的代码部分:

jQuery(document).ready(function() {
        jQuery('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month, agendaWeek, agendaDay'
            },
            allDayText: 'All Day',
            columnFormat: {
                month: 'ddd',
                week: 'ddd d/M',
                day: 'dddd d/M'
            },
            editable: false,
            weekends: true,
            timeFormat: 'h:mm-h:mma ',
            axisFormat: 'hh:mma',
            firstDay: 1,
            slotMinutes: 15,
            defaultView: 'month',
            minTime: '10:00',
            maxTime: '17:00',
            monthNames: ["January","February","March","April","May","June","July", "August", "September", "October", "November", "December" ],
            monthNamesShort: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","nov","Dec"],
            dayNames: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
            dayNamesShort: ["Sun","Mon", "Tue", "Wed", "Thus", "Fri", "Sat"],
            buttonText: {
                today: "Today",
                day: "Day",
                week:"Week",
                month:"Month"
            },
            selectable: true,
            selectHelper: false,
            select: function(start, end, allDay) {

            },

            events: [
                               {
                                        id: "3",
                                        title: "My event title",
                                        start: new Date(2014,10,03,10,0),
                                        end: new Date(2014,10,03,12,0),
                                        allDay: false,
                                        backgroundColor : "#7F97FF",
                                        textColor: "white"
                                    },

问题在于它在10:00-10:00am显示的UI中没有意义。根据我的事件代码,它应该从10,00,00开始到12,00,00结束,那么为什么标题不匹配呢?有人可以帮帮我!

1 个答案:

答案 0 :(得分:1)

您的FullCalendar配置不正确,因为您希望每个事件都有“开始 - 结束”时间。

 timeFormat: 'h:mm-h:mma ', // the output i.e. "10:00-10:00pm"
 timeFormat: 'h:mma ',      // the output i.e. "10:00pm"

 displayEventEnd : true,    // it will show on all views (Start - End) in your timeFormat

我已更新您的JsFiddle,因为您忘记插入外部来源,我已导入FullCalendar库以便工作。