繁体   English   中英

在资源时间线中拖动事件时的 FullCalendar 工具提示错误

[英]FullCalendar tooltip bug when dragging event in Resource timeline

我正在使用 JavaScript FullCalendar 库来构建我的日历。 现在更新我的代码以使用 FullCalendar V4。 在资源时间线视图中拖动事件时,工具提示未按预期工作(拖动时显示重复的工具提示)。 此问题仅发生在资源时间线视图中,而不发生在 dayGrid 视图中。 我附上了两个codepen代码。 Daygrid 视图工作正常,但资源时间线视图没有。
https://codepen.io/nmwangxin/pen/WNeRQaX https://codepen.io/nmwangxin/pen/qBWROKz

eventRender: function(info) {
      var tooltip = new Tooltip(info.el, {
        title: 'test',
        placement: 'top',
        trigger: 'hover',
        container: 'body'
      });
    },

当拖动事件时,它每次都会重新渲染,所以基本上你每次都会重新创建一个新的工具提示,从而创建多个实例,这些实例又会失去对被销毁元素的引用,因此它的位置很奇怪。 我建议挂钩“eventMouseEnter”和“eventMouseLeave”回调并在那里创建和销毁单个工具提示对象。 下面是一个例子:

var tooltip = null;
eventMouseEnter: function(info) {
  tooltip = new Tooltip(info.el, {
    title: info.event.title,
    placement: 'top',
    trigger: 'hover',
    container: 'body'
  });
},
eventMouseLeave:  function(info) {
  if (tooltip) {
    tooltip.dispose();
  }
}

https://codepen.io/alex-hazanov/pen/rNBjPyL

或者像这样使用引导程序的工具提示:

eventMouseEnter: function (info) {
    $(info.el).tooltip({
          title: info.event.title + '<br />' + info.event._instance.range.start,
          html: true,
          placement: 'top',
          trigger: 'hover',
          container: 'body',
    });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM