gpt4 book ai didi

javascript - 我可以在 Bootstrap 弹出窗口中使用动态内容吗?

转载 作者:IT王子 更新时间:2023-10-29 00:17:17 26 4
gpt4 key购买 nike

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

任何人都可以阐明这一点吗?

这是我的。

<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);
}
});
});

关于javascript - 我可以在 Bootstrap 弹出窗口中使用动态内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21459042/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com