Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何让引导弹出窗口在FullCalendar 4中工作?_Javascript_Css_Bootstrap 4_Fullcalendar_Fullcalendar 4 - Fatal编程技术网

Javascript 如何让引导弹出窗口在FullCalendar 4中工作?

Javascript 如何让引导弹出窗口在FullCalendar 4中工作?,javascript,css,bootstrap-4,fullcalendar,fullcalendar-4,Javascript,Css,Bootstrap 4,Fullcalendar,Fullcalendar 4,我在FullCalendar 4中使用Google日历数据,所有内容都显示得很好,但我很难弄清楚如何在悬停事件中使用引导弹出窗口。我在网上找到了很多不同的东西,但它们要么抛出JSON错误,要么什么都不做(可能是因为大部分都是针对以前的版本) 这个特定的eventRender函数不会抛出任何错误,但也不会执行任何操作。mouseover上发生的唯一一件事是在特定事件中将fc allow mouse resize添加到锚定标记。我错过了什么 解决方案(已从popover内容中删除event.desc

我在FullCalendar 4中使用Google日历数据,所有内容都显示得很好,但我很难弄清楚如何在悬停事件中使用引导弹出窗口。我在网上找到了很多不同的东西,但它们要么抛出JSON错误,要么什么都不做(可能是因为大部分都是针对以前的版本)

这个特定的eventRender函数不会抛出任何错误,但也不会执行任何操作。mouseover上发生的唯一一件事是在特定事件中将fc allow mouse resize添加到锚定标记。我错过了什么

解决方案(已从popover内容中删除event.description)


多亏了阿德森。在评论中,他问我的所有事件是否都有描述属性,但没有。我删除了event.description的引用,它解决了我的问题。我的最终代码如下

var calendarEl=document.getElementById('calendar');
var calendar=新的完整日历。日历(calendarEl{
插件:['dayGrid','timeGrid','list','bootstrap','googleCalendar'],
主题系统:“引导”,
googleCalendarApiKey:'xxxxxxx',
活动:{
谷歌日历ID:'xxxxxxx'
},
eventRender:函数(信息){
var start=info.event.start;
var end=info.event.end;
var startTime;
var结束时间;
如果(!开始){
开始时间=“”;
}否则{
开始时间=开始;
}
如果(!结束){
endDate=“”;
}否则{
结束时间=结束;
}
var title=info.event.title;
var location=“at”+info.event.extendedProps.location;
如果(!info.event.extendedProps.location){
地点='';
}
$(info.el).popover({
标题:标题,,
位置:'顶部',
触发器:“悬停”,
内容:开始时间+到结束时间+位置,
容器:'主体'
}).popover(“show”);
},
事件单击:函数(信息){
info.jsEvent.preventDefault();//不要让浏览器导航
if(info.event.url){
打开(info.event.url);
}
},
身高:650,
标题:{
左:'标题',
中心:'',
右图:“dayGridMonth、timeGridWeek、timeGridDay、listWeek prevYear、prev、next、nextYear”
}
});
calendar.render();

我也有同样的问题,这很有效。谢谢

只需一个小的添加:
endDate
应该是下面代码部分的
endTime

if (!end) {
    endDate = '';
} else {
    endTime = end;
}
顺便说一句,我发现这样写比较容易:

var endTime  = (!end) ? '' : end;
我想为日期格式添加一些内容。也许有人会发现它很有用。 我用过:

更专业的是:

var end = info.event.end.toLocaleString('fr-FR',{
                day: '2-digit',
                month: 'short',
                hour: '2-digit',
                minute: '2-digit'
            });

我建议您查看eventRender v4文档:,特别是其中关于回调签名的内容,即传递到回调函数中的参数。您使用的是v3签名。这是我能想到的最接近的一个,获取“解析JSON失败”
eventRender:function(info){info.el.popover({title:info.event.extendedProps.title,位置:'top',触发器:'hover',内容:info.event.extendedProps.description,容器:'body'}).popover('show');},
Ok so 1)根据原始代码判断,我希望.popover()方法是一个jQuery方法?因此从逻辑上讲,它应该是
$(info.el).popover(
在新版本中(因为在v4中元素
el
现在是一个本机DOM元素对象,而不是jQuery对象)由于
title
是一个扩展属性,我认为您不应该在extendedProps中查找它-
info.event.title
应该为您提供所需的数据。因此,在这两种情况下,我想您只需要更详细地检查文档。您对标题的看法是正确的。我尝试使用jQuery选择器,但仍然得到了一些信息“解析JSON失败”。有趣的事实是:如果我从文档中复制示例eventRender代码,我仍然会得到JSON错误。看起来我必须让我的老板来尝试一下。显然,问题是……做(全部)您的事件肯定有一个已填充的
description
属性?可能是无法从一个或多个事件中读取该属性。可能仅尝试使用title属性,因为它们都应该至少具有该属性。
var endTime  = (!end) ? '' : end;
var end = info.event.end.toLocaleString('fr-FR');
var end = info.event.end.toLocaleString('fr-FR',{
                day: '2-digit',
                month: 'short',
                hour: '2-digit',
                minute: '2-digit'
            });