从全日历获取选择的日期 [英] Get selected date from fullcalendar
本文介绍了从全日历获取选择的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从此处将日历添加到了asp.net mvc 2应用程序中.
I added the calendar to my asp.net mvc 2 application from here .
我想选择要进入活动的所选日期.如何获得所选日期?
I want to pick the selected date where I am going to enter the event. How can I get selected date?
我还要将此日期和相应的事件保存到数据库中.还要怎么做?
Also I want to save this date and corresponding event to the database. How to do this also ?
推荐答案
在设置插件时使用此代码
Use this code when you setup the plugin
$('#calendar').fullCalendar({
selectable: true,
select: function(start, end, jsEvent, view) {
// start contains the date you have selected
// end contains the end date.
// Caution: the end date is exclusive (new since v2).
var allDay = !start.hasTime() && !end.hasTime();
alert(["Event Start date: " + moment(start).format(),
"Event End date: " + moment(end).format(),
"AllDay: " + allDay].join("\n"));
}
});
<link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.print.css" rel="stylesheet" media="print"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js"></script>
<div id="calendar"></div>
请注意,我刚刚提供了回答您的问题所需的选项.
Please note that I have just included the options needed to answer your question.
有关更多信息,请参见制作精良的插件文档.
For further information refer to the very good made plugin documentation.
这篇关于从全日历获取选择的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文