年视图中fullcalendar的工具提示

Kar*_*hik 17 jquery fullcalendar

我想在年视图中为fullcalendar添加工具提示.我尝试使用下面的一个,但它在月视图中添加了工具提示.我试过谷歌,但没有找到任何与此相关的内容.有没有其他方法可以在年视图中添加工具提示?

eventMouseover: function(calEvent,jsEvent) {
            xOffset = 10;
            yOffset = 30;
            $("body").append(calEvent.tooltip);
            $("#tooltip")
                .css("top",(jsEvent.clientY - xOffset) + "px")
                .css("left",(jsEvent.clientX + yOffset) + "px")
                .fadeIn("fast");
    },
    eventMouseout: function(calEvent,jsEvent) {
        $("#tooltip").remove(); 
    }
Run Code Online (Sandbox Code Playgroud)

小智 47

eventMouseover: function(calEvent, jsEvent) {
    var tooltip = '<div class="tooltipevent" style="width:100px;height:100px;background:#ccc;position:absolute;z-index:10001;">' + calEvent.title + '</div>';
    var $tooltip = $(tooltip).appendTo('body');

    $(this).mouseover(function(e) {
        $(this).css('z-index', 10000);
        $tooltip.fadeIn('500');
        $tooltip.fadeTo('10', 1.9);
    }).mousemove(function(e) {
        $tooltip.css('top', e.pageY + 10);
        $tooltip.css('left', e.pageX + 20);
    });
},

eventMouseout: function(calEvent, jsEvent) {
    $(this).css('z-index', 8);
    $('.tooltipevent').remove();
},
Run Code Online (Sandbox Code Playgroud)

  • 请将"var $ tootlip"更改为"var $ tooltip".谢谢你的例子.像魅力一样工作 (3认同)

Tan*_*guy 29

您可以在没有任何工具提示库的情况下使用html title属性:

$('#calendar').fullCalendar({
    events: [
        {
            title: 'My Event',
            start: '2014-01-01',
            tooltip: 'This is a cool event'
        }
        // more events here
    ],
    eventRender: function(event, element) {
        element.attr('title', event.tooltip);
    }
});
Run Code Online (Sandbox Code Playgroud)

  • 因为应该使用jQuery 1.6 prop():`element.prop("title",event.title);` (3认同)
  • 很好的帮助!工作得很好.对于那些使用较新版本的fullcalendar的人来说,有一个工具提示功能也可以提供帮助:https://fullcalendar.io/docs/event-display它允许在工具提示中提供更多详细信息. (3认同)

jaf*_*ech 7

作为fullcalendar改变了事件的最新版本为每个文档,我改变了津城的回答几乎没有更详细的解答

弹出窗口看起来像这样

在此处输入图片说明

它不需要任何 js 或 css 插件

您可以使用另一个对象来更改事件数据或有效负载以获取工具提示内容,并在您的 js 中使用它,例如

        events: [
        {
            title: 'My Event',
            start: '2019-01-01',
            popup: {
                title: 'This is the title',
                descri: 'This is the description',
            }
        }
        // more events here
        ],
        eventMouseEnter: function(info) {
            var tis=info.el;
            var popup=info.event.extendedProps.popup;
            var tooltip = '<div class="tooltipevent" style="top:'+($(tis).offset().top-5)+'px;left:'+($(tis).offset().left+($(tis).width())/2)+'px"><div>' + popup.title + '</div><div>' + popup.descri + '</div></div>';
            var $tooltip = $(tooltip).appendTo('body');

//            If you want to move the tooltip on mouse movement then you can uncomment it
//            $(tis).mouseover(function(e) {
//                $(tis).css('z-index', 10000);
//                $tooltip.fadeIn('500');
//                $tooltip.fadeTo('10', 1.9);
//            }).mousemove(function(e) {
//                $tooltip.css('top', e.pageY + 10);
//                $tooltip.css('left', e.pageX + 20);
//            });
        },
        eventMouseLeave: function(info) {
            console.log('eventMouseLeave');
            $(info.el).css('z-index', 8);
            $('.tooltipevent').remove();
        },
Run Code Online (Sandbox Code Playgroud)

工具提示的 css 看起来像上面的截图

.tooltipevent{
    width:200px;/*
    height:100px;*/
    background:#ccc;
    position:absolute;
    z-index:10001;
    transform:translate3d(-50%,-100%,0);
    font-size: 0.8rem;
    box-shadow: 1px 1px 3px 0px #888888;
    line-height: 1rem;
}
.tooltipevent div{
    padding:10px;
}
.tooltipevent div:first-child{
    font-weight:bold;
    color:White;
    background-color:#888888;
    border:solid 1px black;
}
.tooltipevent div:last-child{
    background-color:whitesmoke;
    position:relative;
}
.tooltipevent div:last-child::after, .tooltipevent div:last-child::before{
    width:0;
    height:0;
    border:solid 5px transparent;/*
    box-shadow: 1px 1px 2px 0px #888888;*/
    border-bottom:0;
    border-top-color:whitesmoke;
    position: absolute;
    display: block;
    content: "";
    bottom:-4px;
    left:50%;
    transform:translateX(-50%);
}
.tooltipevent div:last-child::before{
    border-top-color:#888888;
    bottom:-5px;
}
Run Code Online (Sandbox Code Playgroud)


小智 6

从1.5版开始,您可以使用qtip(我也使用tipsy但它应该与工具提示一起使用)来显示事件的提示:

$('#calendar').fullCalendar({
    events: [
        {
            title: 'My Event',
            start: '2010-01-01',
            description: 'This is a cool event'
        }
        // more events here
    ],
    eventRender: function(event, element) {
        element.qtip({
            content: event.description
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

doc来源:http://arshaw.com/fullcalendar/docs/event_rendering/eventRender/

希望这可以帮助