首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有办法在yii中为CTabView选项卡添加工具提示吗?

有办法在yii中为CTabView选项卡添加工具提示吗?
EN

Stack Overflow用户
提问于 2014-02-12 15:27:08
回答 1查看 170关注 0票数 0

我需要为选项卡添加工具提示。有办法在yii中为CTabView选项卡添加工具提示吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-20 11:10:26

我通过fn属性扩展了jQuery对象的功能。

查看文件:

代码语言:javascript
复制
<?php 

Yii::app()->clientScript->registerScript('jquery-tooltip', '
$.fn.tooltip = function(tooltip_text)
{

// Mouse enters the target element
     $(this).on("mouseenter", function()
     {
        // Make the tooltip visible
        $("#tooltip").css("display", "inline");

        // Set custom text
        $("#tooltip").text(tooltip_text);

        // Start listening to the mousemove event, memory is allocated for it
        $(this).on("mousemove", function(event) {
            var x = event.pageX; // get mouse X position relative to the page (screen)
            var y = event.pageY; // get mouse Y position
            x = x + 32;  // move it to the right from the cursor
            y = y - 16;   // move it up
            $("#tooltip").css( {left: x, top: y} );
    });
});

// Mouse leaves the target element
$(this).off("mouseout", function()
{
    // Stop listening to the mousemove event, memory is released
    $(this).off("mousemove");
});

$(this).on("mouseout", function()
{
    // Hide the tooltip
    $("#tooltip").css("display", "none");
});
}
$(document).ready(function()
{
 $("a[href=\'#tab1\']").tooltip("tooltip text1");
 $("a[href=\'#tab2\']").tooltip("tooltip text2");
});
' , CClientScript::POS_END ); 
?>
<div id = "tooltip" '></div> 

一些CSS:

代码语言:javascript
复制
#tooltip {
position: absolute;
width: auto;
display: inline;
padding: 8px;
font-family: Arial;
font-size: 14px;
color: #777777;
font-weight: bold;
border: 1px solid silver;
background: #FFFFEE;        /* Slightly yellow background */
border-radius: 5px;               /* Rounded corners */
box-shadow: 5px 5px 10px #DDD;  /* Tooltip shadow */
z-index: 30000;         /* A very large z-index ensures
                                   it's "always on top" */
}

工作的演示。唯一的一点是:我更改了代码,因为我将“mouseover”替换为“mouseenter”事件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21732147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档