Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery fullCalendar displayed undefined on title

i'm using jQuery fullcalendar on a ReactJs component.

i have a <div id="calendar"></div> on the render method

and on componentDidUpdate , i updated the calendar with the following codes:

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

events: _this.state.events,
defaultView:'month',
displayEventTime: false,
editable: false,
droppable: false,
durationEditable: false
});

and it shows "undefined" character on title. where did i go wrong? and how to debug where the undefined string came from?

jquery full calendar

currently, i made a hacked solution to remove all undefined string from the title by adding the following:

viewRender: function(view, element) {
//note: this is a hack, i don't know why the view title keep showing "undefined" text in it.
//probably bugs in jquery fullcalendar
$('.fc-center')[0].children[0].innerText = view.title.replace(new RegExp("undefined", 'g'), ""); ;

},

is there any better solution?

i'm using jquery FullCalendar v2.9.1

with the following sample data on the events:

[{"start":"2017-03-24T00:00:00.000Z","end":"2017-03-26T00:00:00.000Z","title":"Open house","description":"Bali 1 open house"}]

note: I ended up dumping the jquery full calendar in favor of react-big-calendar.

like image 701
Grand Julivan Avatar asked Apr 05 '17 09:04

Grand Julivan


2 Answers

I was having the same issue after upgrading fullCalendar, took me a bit to figure out because for almost a year everything has been working fine and I had upgraded fullCalendar in the past without any issues, for some reason I had to include moment.js in the page I was using the fullCalendar on, see I run an MVC site and previously the master page (_layout.cshtml) was referencing moment.js, not sure right now why that doesn't work anymore, just as a test I added a reference to moment in the actual page I use fullCalendar and the undefindundefined went away and so did another issue I was having with events.

In my case the fix was:

@Scripts.Render("~/bundles/dates") 

in your case it may just be:

<script src='//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>
like image 195
Devnsyde Avatar answered Sep 28 '22 06:09

Devnsyde


I was having the same issue after upgrading fullCalendar.js from v2.6.1 to v3.4.0

In my case the Issue resolved by including fullcalendar.js & scheduler.min.js after moment.js

like image 31
Haseeb Ibrar Avatar answered Sep 28 '22 06:09

Haseeb Ibrar