未捕获的TypeError:e.replace不是fullcalendar中的函数

时间:2017-05-04 02:20:59

标签: javascript php jquery fullcalendar

我在点击日历中的日期时尝试显示模态。点击模式正确显示。但是所有旧事件都丢失了,我收到了错误

Uncaught TypeError: e.replace is not a function
at nt (fullcalendar.min.js:16)
at _ (fullcalendar.min.js:17)
at O (fullcalendar.min.js:17)
at lt.E [as renderEvents] (fullcalendar.min.js:16)
at R (fullcalendar.min.js:16)
at fullcalendar.min.js:16

我在关闭时发现了一个新错误,然后再点击再次显示模态

Uncaught TypeError: e.replace is not a function
at nt (fullcalendar.min.js:16)
at _ (fullcalendar.min.js:17)
at O (fullcalendar.min.js:17)
at lt.E [as renderEvents] (fullcalendar.min.js:16)
at Z (fullcalendar.min.js:16)
at K (fullcalendar.min.js:16)
at u.O [as renderEvent] (fullcalendar.min.js:16)
at HTMLDivElement.<anonymous> (fullcalendar.min.js:17)
at Function.each (jquery.min.js:186)
at e.fn.init.each (jquery.min.js:63)

HTML:

<script type="text/javascript" src="CaseSurvey/calendarSurvey/calendarSurvey.js"></script>
<div class="row">
    <div class="col-sm-12">
        <div class="box">
            <div class="box-title">
                <h3>
                    <i class="fa fa-calendar"></i>
                    Calendar
                </h3>
            </div>
            <div class="box-content nopadding">
                <div class="calendar2" id="calendar"></div>
            </div>
        </div>
    </div>
</div>
<div id="addEventModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span> <span class="sr-only">close</span></button>
                <h4 class="modal-title">Add Event Title</h4>
            </div>
            <div class="modal-body">
                <label for="eventTitle">Title</label>
                <input type="text" name="eventTitle" id="eventTitle" /><br>
                <label for="eventStart">Start Date</label>
                <input type="text" name="eventStart" id="eventStart" /><br>
                <label for="eventEnd">End Date</label>
                <input type="text" name="eventEnd" id="eventEnd" /><br>
                <input type="radio" id="allday" name="allday" value="1">Half Day
                <input type="radio" id="allday" name="allday" value="2">All Day
                <input type="text" name="title" id="title" value=""/>
            </div>     
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
            </div>
        </div>
    </div>
</div>
<div id="calendarModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span> <span class="sr-only">close</span></button>
                <h4 id="modalTitle" class="modal-title"></h4>
            </div>
            <div id="modalBody" class="modal-body"> </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

calendarSurvey.js:

$(document).ready(function()
{
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();


    var calendar = $('#calendar').fullCalendar(
    {
    header:
    {
        left: 'today',
        center: 'prev,title,next ',
        right: 'month,agendaWeek,agendaDay'
    },

    defaultView: 'month',

    selectable: true,
    selectHelper: true,

    select: function(start, end, allDay)
    {
        $('#addEventModal').modal();
        if (title)
        {
            calendar.fullCalendar('renderEvent',
                {
                    title: title,
                    start: start,
                    end: end,
                    allDay: allDay
                },
                true 
            );
        }
        calendar.fullCalendar('unselect');
    },
    editable: true,
    events: [
        {
            title: 'All Day Event',
            start: new Date(y, m, 1)
        },
        {
            title: 'Long Event',
            start: new Date(y, m, d-5),
            end: new Date(y, m, d-2),
            textColor:'orchid',
            color:'peachpuff'
        },
        {
            id: 999,
            title: 'Repeating Event',
            start: new Date(y, m, d-3, 16, 0),
            allDay: false
        },
        {
            id: 999,
            title: 'Repeating Event',
            start: new Date(y, m, d+4, 16, 0),
            allDay: false
        },
        {
            title: 'Meeting',
            start: new Date(y, m, d, 10, 30),
            color: 'plum',
            allDay: false
        },
        {
            title: 'Lunch',
            start: new Date(y, m, d, 12, 0),
            end: new Date(y, m, d, 14, 0),
            allDay: false
        },
        {
            title: 'Birthday Party',
            start: new Date(y, m, d+1, 19, 0),
            end: new Date(y, m, d+1, 22, 30),
            color: 'salmon',
            allDay: false
        },
        {
            title: 'Click for Google',
            start: new Date(y, m, 28),
            end: new Date(y, m, 29),
            url: 'http://google.com/'
        }
    ],
    eventClick: function(calEvent, jsEvent, view) {


        $('#modalTitle').html(calEvent.title);
        $('#modalBody').html(view.name);
        $('#eventUrl').attr('href',calEvent.url);
        $('#calendarModal').modal();


    }
});
});

我在index.php中包含fullcalendar.min.js

0 个答案:

没有答案