从fullcalendar jquery获取选定的日期 [英] get selected date from fullcalendar jquery

查看:157
本文介绍了从fullcalendar jquery获取选定的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从此处将我的日历添加到了我的asp.net mvc 2应用程序中。
我想选择我要进入活动的选定日期。我如何获得选定的日期?另外我想将这个日期和相应的事件保存到数据库中。如何做到这一点呢?
我是新来的jequery。请帮助!

解决方案

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

 $('#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.

这篇关于从fullcalendar jquery获取选定的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆