jQuery FullCalendar - 尝试添加事件并在日历上显示失败
我正在尝试研究如何使用 Adam Shaw 出色的 jQuery 插件 - FullCalendar 在我们的项目中添加一个事件:在线正在开发的气球订购页面
基本上,如果您点击“step1”并选择“店内提货”,页面将带您进入日历视图,您可以在其中点击右上角的“星期” “ 按钮 将视图更改为每周一次。我想要实现的是,当客户点击一天中的一个空位时,她可以在该位置创建她的活动。这是我在 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所以要创建这样一个活动。但是,尽管我的代码运行没有错误,并且我可以看到提示说明已单击哪个插槽,但它不会在日历上呈现这样的新事件。
还有其他方法可以做到这一点还是我的代码出了问题?
任何建议将不胜感激,非常感谢。
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
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),
});
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个简单的疏忽。函数
loadCalender(type)
中的type
值通过调用closeStep1OpenSetp2("pickupCalendar");< 设置为
pickupCalendar
/代码>。但是您执行
$('#' + type + 'Calendar')
,其计算结果为$('#pickupCalendarCalendar')
并且没有具有此 id 的元素。正确的做法是$('#pickupCalendar')
,因此要么删除参数中的 Calendar,要么放弃+ 'Calendar'
。那么它应该可以正常工作It's a simple oversight. The value of
type
in the functionloadCalender(type)
is set topickupCalendar
from the callcloseStep1OpenSetp2("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