简体   繁体   English

带有链接和PHP的Bootstrap Popover

[英]Bootstrap popover with link and PHP

I'm trying to use bootstrap popover to pop a confirmation window before deleting a record from my database-driven table. 我试图使用引导程序弹出窗口弹出确认窗口,然后再从数据库驱动的表中删除记录。 The code used to generate column with delete buttons looks like this: 用于使用删除按钮生成列的代码如下所示:

echo "<td> <div class=\"popover-example list-inline\"><a class=\"btn btn-primary\" data-toggle=\"popover\" title=\"Are you sure?\" data-content=\"<a href=\"delete.php?id='. $row->id.' \">Delete</a></div></td>";

and my popover js looks like this: 我的popover js看起来像这样:

$(document).ready(function(){
    $(".popover-example a").popover({
        placement : 'top'
        html: 'true'
    });
});

I know, that this echo is bit messy, but it works with plain text. 我知道,此回声有点混乱,但它适用于纯文本。 I'd like to make the HTML with dynamically generated link appear in poprover. 我想使带有动态生成链接的HTML出现在poprover中。 Is there any way to do it? 有什么办法吗? I'd be grateful for a tip. 我将不胜感激。

You can add dynamic and custom content in a popover like so 您可以像这样在弹出窗口中添加动态和自定义内容

var myDynamicContent = $('<a>').attr('href', 'http://www.yahoo.com')
    .text('click here!');

$(".popover-example a").popover({
    placement : 'top'
    html: 'true'
    content: myDynamicContent
});

The content key of the popover plugin allows you to add custom content when the popover is triggered to open. popover插件的content键允许您在触发打开弹出窗口时添加自定义内容。 You can also embed that value in the HTML markup, as a data-content="" value. 您也可以将该值作为data-content=""值嵌入HTML标记中。

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

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