Is Fullcalendar v2.6.0 able to work on jQuery-3.3.1 and MVC 5? I have an old project which needs to be upgraded. I am using Visual Studio 2017 with jQuery-3.3.1, MVC 5.2.4 and moment.min.js 2.24 to recompile it, but I always got an error when I use IE 11:
Unhandled exception at line 3827, column 3 in http://localhost:61158/Scripts/jquery-3.3.1.js 0x800a138f - JavaScript runtime error: Unable to get property 'format' of undefined or null reference
When I use Google Chrome to debug it, I got an error message is:
Uncaught TypeError: Cannot read property 'format' of null
Anyone has any ideas? Thanks.
Sorry, this is my calendar code in index.cshtml.
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
theme: true,
aspectRatio: 2,
defaultDate: '@DateTime.Now.ToString("MM-dd-yyyy")',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: {
url: '@Url.Action("GetCalendarEvents")',
error: function () {
$('#script-warning').show();
}
},
eventClick: function (calEvent, jsEvent, view) {
//set the values and open the modal
//var winWidth = $(window).width();
//var dialogWidth = winWidth * 0.5;
var gdiv = $("#eventInfo");
if (gdiv != null) gdiv.empty();
$.ajaxSetup({ cache: false });
var request = $.ajax({
type: "GET",
url: calEvent.ajaxUrl,
data: {}
});
request.done(function (returndata) {
$("#eventInfo").html(returndata);
});
request.fail(function (jqXHR, status) {
alert("Error repopulating grid : " + status + "");
});
$.ajaxSetup({ cache: true });
}
});
});
</script>
Here's a JSFiddle using those library versions (the MVC version is irrelevant since that only affects server-side code): http://jsfiddle.net/g2np7wt9/2/
You didn't post your own code unfortunately, so I used a very basic calendar setup for the test:
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
}
});
});
It does indeed produce the error mentioned in your question, so the short answer is no, this combination of library versions doesn't work.
So your options are
a) downgrade the version of jQuery until the problem stops (2.2.4 seems to be the last version it works with, based on some quick tests)
or (probably better)
b) upgrade your version of fullCalendar, since 2.x is legacy now. 3.x is almost 100% API-compatible with 2.x, but does work with newer jQuery. See https://fullcalendar.io/blog/2016/09/feature-packed-releases. 4.x is a much bigger change but it may be worth it in the long run, since that's where the future lies in terms of new features, bug fixes etc. Also 4.x doesn't require jQuery or momentJS, so that headache would disappear entirely... see https://fullcalendar.io/docs/upgrading-from-v3.
I upgraded fullCalendar to V3.9 and it is working right now. There is no error anymore except for a warning: Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to momentjs.com/guides/#/warnings/js-date for more info. But at lease the calendar is working correctly on my web app. Thanks for everyone's help. If you have any idea about the above warning, please let me know.
User contributions licensed under CC BY-SA 3.0