简体   繁体   中英

Bootstrap Displaying PopOver Dynamically

I am trying to create a Bootstrap popup dynamically. 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. Try calling 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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