【发布时间】:2018-09-11 17:22:26
【问题描述】:
我使用webui popover 我的代码是:
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 调用。
【问题讨论】:
-
.webuiPopover('hide');那么 .webuiPopover('destroy') 这个不行吗?
-
我应该在哪里添加那行代码 @AnyMoose ? $(pre_elem_at).webuiPopover('hide'); $(pre_elem_at).webuiPopover('destroy');
-
是的,尝试将 $(pre_elem_at).webuiPopover('destroy') 替换为 $(pre_elem_at).webuiPopover('hide')...
-
不,它不起作用.. 如果我将“destroy”替换为“hide”,它会生成此错误而不是
TypeError: $(...).webuiPopover(...).webuiPopover is not a function.. -
我认为
type:'async',有问题,因为如果我删除它。弹出框工作得很好,但它会是空白的,因为它没有从指定的 url 获取数据..
标签: jquery arrays popover webui