jQuery 年视图中全日历的工具提示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9802179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 11:20:03  来源:igfitidea点击:

Tooltip for fullcalendar in year view

jqueryfullcalendar

提问by Karthik

I want to add tooltip for the fullcalendar in year view. I tried with the below one but it added tooltip to month view. I tried with google but did not find anything related to this. Is there any other way to add a tooltip in year view?

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

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(); 
    }

回答by jincheng

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();
},

回答by Tanguy

You can use the html title attribute without any tooltip lib :

您可以在没有任何工具提示 lib 的情况下使用 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);
    }
});

回答by anybug

since 1.5 version, you can use qtip (i also use tipsy but it should work with tooltip) to display a tip on an event:

从 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
        });
    }
});

doc source: http://arshaw.com/fullcalendar/docs/event_rendering/eventRender/

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

hope this helps

希望这可以帮助

回答by jafarbtech

As fullcalendar has changed the events in the latest version as per the documentationI am changing the jincheng's answerwith little more detailed answer

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

The popup will look like this

弹出窗口看起来像这样

enter image description here

在此处输入图片说明

It doesn't need any js or css plugins

它不需要任何 js 或 css 插件

you can change the event data or payload with one more object for tooltip stuff and use it in your js like

您可以使用更多的工具提示对象更改事件数据或有效负载,并在您的 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();
        },

The css for the tooltip to look like the above screenshot

工具提示的 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;
}

回答by user7373835

Here another implementation

这是另一个实现

eventMouseover: function(calEvent, jsEvent) { var tooltip = '<div class="tooltipevent" style="width:130px;height:100px;background:#aed0ea;position:absolute;z-index:10001;"> Title: ' + calEvent.title + '</div>'; var $tool = $(tooltip).appendTo('body');
$(this).mouseover(function(e) {
    $(this).css('z-index', 10000);
            $tool.fadeIn('500');
            $tool.fadeTo('10', 1.9);
}).mousemove(function(e) {
    $tool.css('top', e.pageY + 10);
    $tool.css('left', e.pageX + 20);
});
},
eventMouseout: function(calEvent, jsEvent) {
$(this).css('z-index', 8);
$('.tooltipevent').remove();
},