我可以在Bootstrap popover中使用动态内容吗? [英] Can I use dynamic content in a Bootstrap popover?

查看:140
本文介绍了我可以在Bootstrap popover中使用动态内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在重复区域中使用Bootstrap Popover来显示推荐书。每个推荐都有一个查看属性详细信息按钮,可以打开弹出窗口。在Pop中我希望显示与每个推荐和图像细节相关联的图像。图像路径存储在数据库的一列中,以便显示我需要将图像源绑定到内容的每个推荐的图像,但它不接受PHP。我使用的脚本允许我将html写入内容,但需要动态创建图像。动态文字适用于'a'标记'标题'选项但不适用于内容。

I am using a Bootstrap Popover in a 'Repeat Region' which displays Testimonials. Each testimonials has a 'View Property Details' button which opens up the popover. In the Pop over I am wanting to display the image associated with each testimonial and details of the image. The image path is stored in a column in the database so to display the image for each testimonial I need to bind the image source to the content but it is not accepting PHP. I am using a script that allows me to write html into the content but the image needs to be created dynamically. Dynamic text works in the 'a' tag 'title' option but not for Content.

任何人都可以了解这一点吗?

Can anyone shed light on this?

这就是我所拥有的。

<script type="text/javascript">
 $(document).ready(function() {
  $("[rel=details]").popover({
  placement : 'bottom', //placement of the popover. also can use top, bottom, left or     right
  html: 'true', //needed to show html of course
  content : '<div id="popOverBox"><img src="<?php echo $row_rsTstmnlResults['image']; ?>"        width="251" height="201" /></div>' //this is the content of the html box. add the image here or anything you want really.
});
});
</script>
    <a href="#" rel="details" class="btn btn-small pull-right" data-toggle="popover"     title="<?php echo $row_rsTstmnlResults['property_name']; ?>" data-content="">View Property</a>


推荐答案

var popover = $("[rel=details]").popover({
    trigger: 'hover',
    placement: 'bottom',
    html: 'true'
}).on('show.bs.popover', function () {
    //I saw an answer here  with 'show.bs.modal' it is wrong, this is the correct, 
    //also you can use   'shown.bs.popover to take actions AFTER the popover shown in screen.
    $.ajax({
        url: 'data.php',
        success: function (html) {
            popover.attr('data-content', html);
        }
    });
});

这篇关于我可以在Bootstrap popover中使用动态内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆