首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >webui弹出窗口未关闭

webui弹出窗口未关闭
EN

Stack Overflow用户
提问于 2018-09-12 01:22:27
回答 1查看 539关注 0票数 0

我正在使用webui popover,我的代码是:

代码语言:javascript
复制
for(var i=0; i<posts.length; i++){

pre_elem_at = document.createElement("a");
                        pre_elem_at.setAttribute("class", "show-pop-async");
                        pre_elem_at.setAttribute("href", "javascript:void(0)");
                        pre_elem_at.setAttribute("style", "font-size: 14px;margin-left: 15px;background-color: white;padding: 5px;cursor: pointer;");
                        pre_elem_at.innerHTML = 'Get Link';
                        pre_elem_at.post_id = posts[i].id;
                        // $(pre_elem_at).webuiPopover();

                        $(pre_elem_at).webuiPopover('destroy').webuiPopover({
                            type:'async',
                            url:'timeline/pullrequest/share_post?share_link=1&cred='+posts[i].id,
                            content:function(data){

                                data = JSON.parse(data);
                                var html ='<div style="margin:0px; width:100%; overflow:hidden;" class="input-group mb-3">';
                                html += '<div class="input-group-prepend">';
                                html += '<button style="border-radius:2px 0 0 2px;" class="btn btn-primary btn-outline-secondary" type="button">Copy</button>';
                                html += '</div>';
                                html += '<input style="color:#333" value="'+data.share_link+'" type="text" class="form-control" placeholder="" aria-label="" aria-describedby="basic-addon1">';
                                html += '</div>';
                                return html;
                        },
                        width:'397',
                        height:'16',
                        padding:false,
                        margin:false,
                         trigger: 'click',
                        cache:false,
                        multi:false

                    });
}

它工作得很好,但我有一个问题..百宝箱不关了..甚至我添加了'closeable:true‘并点击了"x“图标..它仍然不能关闭..如果我移除type:async属性,它将正确关闭弹出窗口,但我无法在其中加载div。因为它是一个ajax调用。

EN

回答 1

Stack Overflow用户

发布于 2018-09-12 03:25:38

我在pre_elem_at.addEventListener上添加了webui popover initiation

代码语言:javascript
复制
pre_elem_at.addEventListener("click",function(e){
                            var pid = e.target.post_id;
                            $(this).webuiPopover({
                            type:'async',
                            url:'timeline/pullrequest/share_post?share_link=1&cred='+pid,
                            content:function(data){

                                data = JSON.parse(data);
                                var html ='<div style="margin:0px; width:100%; overflow:hidden;" class="input-group mb-3">';
                                html += '<div class="input-group-prepend">';
                                html += '<button style="border-radius:2px 0 0 2px;" class="btn btn-primary btn-outline-secondary" type="button">Copy</button>';
                                html += '</div>';
                                html += '<input style="color:#333" value="'+data.share_link+'" type="text" class="form-control" placeholder="" aria-label="" aria-describedby="basic-addon1">';
                                html += '</div>';
                                return html;
                        },
                        width:'397',
                        height:'16',
                        padding:false,
                        margin:false,
                         trigger: 'click',
                        cache:false,
                        multi:false
                    });
                    $(this).webuiPopover('show');
                });

并在我的索引文件中添加了webui销毁程序

//更新排除popover

代码语言:javascript
复制
$(document).on('blur','.show-pop-async, .xpopover',function(e){
var xthis = this;
setTimeout(function(){
   elem = document.activeElement; // This is the element that has focus
   str = $(elem).attr('class');
   arr = str.split(" ");
   n = arr.includes("xpopover");
    if(!n){
      $('.show-pop-async').webuiPopover('destroy');
    }

},1);

});

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

https://stackoverflow.com/questions/52281167

复制
相关文章

相似问题

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