jQuery FullCalendar - 尝试在日历上添加事件和显示失败

问题描述:

我想了解如何使用Adam Shaw的精采jQuery插件 - FullCalendar在我们的项目中添加事件:在线弹窗订购正在开发的页面

I am trying to work out how to use Adam Shaw's brilliant jQuery plugin - FullCalendar to add an event on our project : online balloon ordering page under development

基本上,如果您点击step1并选择在店内取货,该页面将带您到日历视图你可以点击周按钮的右上角
来改变视图到每周。我想实现的是当客户端点击一个空插槽中的一天,她可以创建她的活动在这一点上。这是我的代码在custom.js:

Basically, if you click on "step1" and choose "pickup in shop" , the page will bring you to the calendar view, where you could click on the upper-right corner at the "week" button to alter the view to a weekly basis. What I am trying to achieve is when client clicks on an empty slot in a day, she can create her event on that spot. Here is my code in custom.js:

dayClick: function() 
            {

                var n = parseInt(this.className.match(/fc\-slot(\d+)/)[1]);
                alert('a day has been clicked on slot ' + n);

                //trying to add an event using the renderEvent() method.
                $('#' + type + 'Calendar').fullCalendar('renderEvent', 
                        {
                            title : 'my pickup slot',
                            start : new Date(y,m,d, 12, 30),
                            end   : new Date(y,m,d, 13, 00),
                        });
            }

它尝试使用FullCalendar的API方法renderEvent ,以便创建此类事件。但是,虽然我的代码运行没有错误,我可以看到提示说哪个插槽被点击,它不会在日历上渲染这样一个新的事件。

It tries to use the FullCalendar's API method renderEvent so to create such an event. However, although my code runs without error and I can see the prompt saying which slot has been clicked, It wouldn't render such an new event on calendar.

另一种方法来做这个或我的代码做错了什么?

Is there another way to do this or my code does something wrong?

任何建议都将非常感谢,非常感谢,提前。

Any suggestion would be much appreciated, thanks a lot in advance.

这是一个简单的疏忽。 loadCalender(type)中的类型的值设置为 pickupCalendar closeStep1OpenSetp2(pickupCalendar);

It's a simple oversight. The value of type in the function loadCalender(type) is set to pickupCalendar from the call closeStep1OpenSetp2("pickupCalendar");.

c> $('#'+ type +'Calendar'),其计算结果为 $('#pickupCalendarCalendar')这个id。正确的将是 $('#pickupCalendar')所以要么删除日历中的参数或沟槽 +'日历' 。那么它应该工作很好

But you do $('#' + type + 'Calendar') which evaluates to $('#pickupCalendarCalendar') and there is no element with this id. Correct would be $('#pickupCalendar') so either remove Calendar in the parameter or ditch the + 'Calendar'. Then it should work just fine