webuiPopover的使用

本文介绍了webui-popover的使用方法,包括通过jQuery进行传统引入的方式,并提供了示例页面链接。在实际使用中,可能遇到显示后再次显示时,webui-popover-content高度增加18px的问题,需要注意处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://github.com/sandywalker/webui-popover

示例页

如是使用jquery,老式的引入方式

<link rel="stylesheet" href="/loft-desktop/webui-pop/webui-pop.min.css">

<script type="text/javascript" src="/loft-desktop/webui-pop/webui-pop.min.js"></script>

npm之类的引入请见上部链接

使用实例:

$("#id").webuiPopover(
                        {
                            title:popTitle,//标题
                            cache:true,
                            container: document.body,
                            content: contentStr,//内容
                            animation:'pop',
                            placement:'right-top',
                            trigger:'manual',//手动显示隐藏的形式
                            width: 400,
                            height: 240
                    });

显示(因为在显示之后再次显示,webui-popover-content的height会莫名其妙的增加18px,导致处理麻烦)

/* 详情的pop窗 */
$("#").off("click", '.').on("click", '.', function (e) {
    e.stopPropagation();

    let rowid = $(this).closest("tr.jqgrow").attr("id");
    let data = $('#').grid('getRowData', rowid);

    if(context.options.popIdName == "#applyContent_"+rowid){
        $("#applyContent_"+rowid).webuiPopover('hide');
        context.options.popIdName = '';
    }else{
        context.options.popIdName = "#applyContent_"+rowid;
        $("#applyContent_"+rowid).webuiPopover('show');//显示

        let idStr = '#webuiPopover' + (Number(rowid.split('jqg')[1]) - 1);
        if(!context.options.flagObj[rowid]){
            if(context.options.count == 0){
                $(idStr+' .webui-popover-content').css('height',(Number($(".webui-popover-content").css('height').split('px')[0]) + 18)+'px');
            }else{
                $(idStr+' .webui-popover-content').css('height',(Number($(".webui-popover-content").css('height').split('px')[0]) + 0)+'px'); 
            }
            context.options.count++;   
            context.options.flagObj[rowid] = true;
        }else{
            $(idStr).css('top',(Number($(idStr).css('top').split('px')[0]) + 18)+'px');
            $(idStr+">.arrow").css('top',(Number($(idStr+">.arrow").css('top').split('px')[0]) - 18)+'px');
        }
    }  
});

隐藏

//点击其他区域则关闭pop
$(document).on("click",function(e){
    var selected = e.target || e.srcElement;

    let $item = $(e.target);
    let parents = $item.parents('.webui-popover');//找寻含有class为webui-popover的父元素,结果为集合
    
    if(parents.length == 0){
        $(context.options.popIdName).webuiPopover('hide');
        context.options.popIdName = '';
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值