且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从fullcalendar jquery获取选定的日期

更新时间:2023-01-31 16:14:36

当您设置插件时使用此代码

 $('#calendar')。fullCalendar({selectable:true,select:function(start,end,jsEvent,view){/ / start包含您选择的日期// end包含结束日期//注意:结束日期是独占的(自v2以来新增)var allDay =!start.hasTime()&&!end.hasTime() ; alert([Event Start date:+ moment(start).format(),Event End date:+ moment(end).format(),AllDay:+ allDay] .join(\\\
));}});

< link href =// cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css =stylesheet/& gt;< link href =// cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.print.css =stylesheetmedia =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>



请注意,我刚刚列入了回答您的问题所需的选项。



有关更多信息,请参阅非常好的插件文档


I added the calender 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 ? I am new in jequery. please help!

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.