jQuery fullCalendar在标题上显示为未定义 [英] jQuery fullCalendar displayed undefined on title
问题描述
我有一个< div id =calendar>< p>< / div>
对渲染方法
和componentDidUpdate,我使用以下代码更新日历:
$('#calendar')。fullCalendar({
header:{
left:'prev,next today',
中心:'title',
右:'month,agendaweek,agendaDay'
},
events:_this.state.events,
defaultView:'month ',
displayEventTime:false,
editable:false,
droppable:false,
durationEditable:false
});
,并在标题上显示未定义字符。
我哪里出错了?
以及如何调试未定义字符串的来源?
目前,
i做了一个黑客攻击的解决方案,通过添加以下内容,从标题中删除所有未定义的字符串:
viewRender:function(view,element){
//注意:这是一个黑客攻击,我不知道为什么视图标题会在其中显示未定义文本。
//可能是jquery fullcalendar中的错误
$('。fc-center')[0] .children [0] .innerText = view.title.replace(new RegExp(undefined,'g '),); ;
},
有没有更好的解决方案?
我使用jquery FullCalendar v2.9.1
和以下有关事件的示例数据:
[{start:2017-03-24T00:00:00.000Z,end:2017-03-26T00:00:00.000 Z,title:Open house,description:Bali 1 open house}]
注意:我最终将jquery完整日历转储为react-big-calendar。
升级fullCalendar后出现同样的问题,花了我一点时间,因为近一年来一切正常,我过去升级了fullCalendar而没有任何问题,由于某些原因,我必须包含时刻.js
在我使用fullCalendar的页面上,看到我运行了一个MVC站点,之前是母版页( _layout.cshtml
)是引用 moment.js
,现在还不确定为什么这不起作用更多,就像我在实际的页面中添加了对时刻的引用的测试一样,我使用fullCalendar并且undefindundefined消失了,另外一个问题是我遇到的事件。
在我的情况下,修复程序是: 在您的情况下,它可能只是: i'm using jQuery fullcalendar on a ReactJs component. i have a and on componentDidUpdate , i updated the calendar with the following codes: and it shows "undefined" character on title.
where did i go wrong?
and how to debug where the undefined string came from? currently,
i made a hacked solution to remove all undefined string from the title by adding the following: is there any better solution? i'm using jquery FullCalendar v2.9.1 with the following sample data on the events: note: I ended up dumping the jquery full calendar in favor of react-big-calendar. 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 In my case the fix was: in your case it may just be:
这篇关于jQuery fullCalendar在标题上显示为未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ p $ @ Scripts.Render(〜/ bundles / dates)
code>
< script src ='// cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>
<div id="calendar"></div>
on the render method$('#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
});
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'), ""); ;
},
[{"start":"2017-03-24T00:00:00.000Z","end":"2017-03-26T00:00:00.000Z","title":"Open house","description":"Bali 1 open house"}]
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.@Scripts.Render("~/bundles/dates")
<script src='//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>