FullCalendar dayClick功能

时间:2010-08-03 00:40:37

标签: jquery javascript-events fullcalendar

我对FullCalendar很新,但完全喜欢它的功能。 我正在尝试使用dayClick函数。也许有人可以指导我朝着正确的方向前进。

我现在有这个。

dayClick:function(date,allDay,jsEvent,view){                 var titleNew = prompt('Event Title:');                 var thedate1 = formatDate(date);

            $.ajax({
                url: "classes/class.Post.php?a=dayClickCalendarEvent",
                dataType: 'json',
                data: { 
                      title: titleNew,
                      start: thedate1,
                      end: thedate1
                },
                success: function (data, response, event, date) {

                    $('#calendar').fullCalendar('renderEvent', titleNew);
                },
                error: function () {
                    alert("Oops! Something didn't work");
                }
            });
        },

我的问题是,无论如何,我都无法将事件发送到日历。 我错过了什么吗?我正在使用calEvent,我在另一个StackOverflow帖子中找到它。

任何帮助将不胜感激。谢谢。

2 个答案:

答案 0 :(得分:1)

嘿,我感谢您的回复,我能够使用此代码并且响应很好!

     dayClick: function (date, allDay, jsEvent, view) {
           titleNew = prompt('Event Title:');
           var thedate1 = formatDate(date);

            $.ajax({
                url: "classes/class.Post.php?a=dayClickCalendarEvent",
                dataType: 'json',
                data: { 
                      title: titleNew,
                      start: thedate1,
                      end: thedate1
                },
                success: function (data, response, event, date) {
                    //alert("success here");
                    $('#calendar').fullCalendar('renderEvent',
                    {
                        title: titleNew,
                        start: thedate1,
                        end: thedate1
                    }, true);
                },
                error: function () {
                    alert("Oops! Something didn't work");
                }
            });
        },

答案 1 :(得分:0)

我认为问题出在本声明$('#calendar').fullCalendar('renderEvent', titleNew);

titleNew是一个字符串,renderEvent函数接受一个calEvent对象。

来自FullCalendar文档:

  

事件必须是具有标题的事件对象,并且至少从头开始。   通常,一旦日历重新获取其事件源,事件将消失(例如:单击prev / next时)。但是,将stick指定为true将导致事件永久固定到日历。

我很好奇你为什么要使用Ajax调用,看起来你似乎没有用它做任何事情。