简体   繁体   English

ASP.NET MVC5 jQuery FullCalendar获取事件问题

[英]ASP.NET MVC5 jQuery FullCalendar get events issue

I am trying to get FullCalendar and ASP.Net MVC5 working together for a room booking application. 我想让FullCalendar和ASP.Net MVC5一起为房间预订应用程序工作。

After much searching and testing I discovered a comment which suggested that there were compatibility issues between various versions of FullCalendar and jQuery. 经过大量搜索和测试后,我发现一条注释,表明在FullCalendar和jQuery的各个版本之间存在兼容性问题。

However I finally got the view js script 'events' to fire the controller action, but only by cutting and pasting the various fullcalendar.js and jquery.js scripts from a working sample program I downloaded, which is using FullCalendar v1.6.4 and jQuery v1.10.2. 但是,我最终得到了视图js脚本“事件”来触发控制器动作,但这只能通过从我下载的工作示例程序(使用FullCalendar v1.6.4和jQuery)中剪切并粘贴各种fullcalendar.js和jquery.js脚本来实现。 v1.10.2。 (Thanks https://github.com/venkatbaggu/jqueryfullcalendaerasp.netmvc ) (感谢https://github.com/venkatbaggu/jqueryfullcalendaerasp.netmvc

Given that the current versions of both are FullCalendar v2.4.0 and jQuery v2.2.3 the ones I got working are very old. 鉴于两者的当前版本均为FullCalendar v2.4.0和jQuery v2.2.3,因此我可以使用的版本非常旧。

I'm pretty new to MVC and jQuery so can anyone please advise: 我对MVC和jQuery很陌生,所以任何人都可以建议:

  • what impact will using these very old versions have on my code in the future. 将来使用这些非常旧的版本会对我的代码产生什么影响。
  • can anyone advise of a later combination which works. 谁能建议以后的组合有效。 I would really like to use FullCalendar v2 as I believe there are better display options. 我真的想使用FullCalendar v2,因为我相信会有更好的显示选项。

FYI the js view script I am using is as follows. 仅供参考,我正在使用的js视图脚本如下。 I have also tried many others, including a simple 我还尝试了许多其他方法,包括

events: "/home/getevents"

.. ..

@section scripts{
<script type="text/javascript">

    $(document).ready(function () {
        $('#calendar').fullCalendar({
            theme: true,
            header: {
                left: 'today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },

            defaultView: 'month',
            editable: true,
            allDaySlot: false,
            slectable: true,
            slotMinutes: 15,
            eventSources: [{

                url: '@Url.Action("GetEvents", "Home")',
                type: 'GET',
                error: function () {
                        alert('there was an error while fetching events!');
                    }
                }]
        });
    });


</script>

This is likely too late to help you but may help someone else that comes across this question, because you didn't actually describe the problem you had but managed to get version 1 working I am guessing you had the same issue I did. 这可能为时已晚,无法帮助您,但可能会帮助遇到此问题的其他人,因为您实际上并未描述您所遇到的问题,但设法使版本1正常工作,我想您也遇到了同样的问题。

In version 1 of full calendar the GET parameters start and end are UNIX timestamps (seconds since 1970). 在完整日历的版本1中,GET参数的开始和结束是UNIX时间戳(自1970年以来的秒数)。 This means any examples using version 1 have an action that takes in 2 strings then converts them. 这意味着使用版本1的任何示例都具有一个操作,该操作接受2个字符串,然后将其转换。

This is not the case with versions 2 and 3, the GET parameters are ISO8601 date strings, after looking at an example my action was set up to receive two strings but the action was never called. 在版本2和版本3中不是这种情况,GET参数是ISO8601日期字符串,在查看示例之后,我的操作被设置为接收两个字符串,但从未调用该操作。 I changed the parameters to DateTime and the action was called successfully. 我将参数更改为DateTime并成功调用了该操作。

Here is a working fiddle using version 3. 这是使用版本3的有效小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM