简体   繁体   English

引导程序动态显示PopOver

[英]Bootstrap Displaying PopOver Dynamically

I am trying to create a Bootstrap popup dynamically. 我正在尝试动态创建Bootstrap弹出窗口。 I am using the following code but it does not show anything. 我正在使用以下代码,但未显示任何内容。

function showDictionaryPopup(term) {

// create popover div
var popoverDiv = $("<div>");

popoverDiv.attr("data-toggle","popover");
popoverDiv.attr("data-content","This is a test");
popoverDiv.addClass("row");

popoverDiv.popover();

$("body").append(popoverDiv);

}

I do not get any errors or anything.. 我没有任何错误或其他任何信息。

Looks like you are appending the div to the DOM but never letting the popover be shown. 看起来您是将div附加到DOM,但从不显示弹出窗口。 Try calling popoverDiv.popover('show'); 尝试调用popoverDiv.popover('show');

You may also want to add some content to the popover. 您可能还需要向弹出框添加一些内容。 All the available options can be found here: http://getbootstrap.com/javascript/#popovers 所有可用的选项都可以在这里找到: http : //getbootstrap.com/javascript/#popovers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM