我在开发服务器上使用FullCalendar 1.6.4(PHP 5.5.21)。我理解这个错误(TypeError:calendar.fullCalendar不是函数)在不使用正确版本的javascript和/或查询时或者脚本无序加载时很常见。我已经仔细检查并认为我已经加载了正确的:
<script src='/js/jquery-1.10.2.js'></script>
<script src='/js/bootstrap.min.js'></script>
<script src='/s/js/jquery.ui.core.js'></script>
<script src='/s/js/jquery.ui.widget.js'></script>
<script src='/s/js/jquery.ui.datepicker.js'></script>
<script src='/s/js/jquery.ui.dialog.js'></script>
<script src='/s/js/jquery.ui.position.js'></script>
<script src='/s/js/jquery.ui.mouse.js'></script>
<script src='/s/js/jquery.ui.draggable.js'></script>
<script src='/s/js/jquery.ui.droppable.js'></script>
<script src='/s/js/jquery.ui.resizable.js'></script>
<script src='/s/js/fullcalendar.js'></script>
我已经多次重新安排了加载顺序而没有找到解决方案。帮助
这是有问题的代码。当然,这只是代码的一小部分。如果您需要了解更多内容,请与我们联系。
$(document).ready(function()
{
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar(
{...
$( "#add-event" ).dialog({
dialogClass: "no-close",
autoOpen: false,
position: { my: "center", at: "center", of: calendar },
height: 'auto',
width: 'auto',
autoResize: true,
resizeable: false,
closeOnEscape: true,
modal: true,
title: 'Add Event',
buttons: {
"Save Event": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( title, "title", 3, 75 );
bValid = bValid && checkLength( description, "description", 6, 255 );
//bValid = bValid && checkLength( url, "url", 5, 255 );
if ( bValid ) {
$.ajax({
type: "POST",
url: 'add_events.php',
data: $('#add-event-form').serialize() +"&start="+ eventStart +"&end="+ eventEnd,
success: function() {
calendar.fullCalendar('refetchEvents');
}
});
$( this ).dialog( "close" );
}
},
...
明显的问题是$ .ajax调用中的引用:
calendar.fullCalendar('refetchEvents');
感谢。我迫不及待地想知道我是如何浪费这么多时间来让它发挥作用的。