简体   繁体   中英

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.

After much searching and testing I discovered a comment which suggested that there were compatibility issues between various versions of FullCalendar and 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. (Thanks 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.

I'm pretty new to MVC and jQuery so can anyone please advise:

  • 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.

FYI the js view script I am using is as follows. 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.

In version 1 of full calendar the GET parameters start and end are UNIX timestamps (seconds since 1970). This means any examples using version 1 have an action that takes in 2 strings then converts them.

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. I changed the parameters to DateTime and the action was called successfully.

Here is a working fiddle using version 3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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