【问题标题】:Unable to show Base64 image in Popover, Bootstrap无法在 Popover、Bootstrap 中显示 Base64 图像
【发布时间】:2014-03-12 07:02:51
【问题描述】:

情况是,我想在bootstrap popover v2.3.1中打开一个图像 并且图像是Base64格式。 单击按钮 [id='imagePopoverButton'] 时,弹出窗口正在打开,但未显示 base 64 图像。

我正在分享下面的代码 sn-p,如果有人可以帮助我解决同样的问题。

<!-- js func, which load Base 64 img format via Ajax -->

function showImagePopover() {
            $.ajax({
                url : getContextPath()
                        + "/app/Application/showImagePopover",
                type : 'POST',
                async : false,
                success : function(jqXHR) {
// In this scope, i have fetched the ajax image, but i am not been able 
//to show that up in popover
                }
            });
        }
/***************************************************************/
<!-- Popover function js, html:true -->

$("#imagePopoverButton").popover({
        content : showImagePopover(),
        html : true,
        trigger : 'click',
        placement : 'right',

    });

/***************************************************************/

<!-- via Clicking of the button, ajax call is suppose to load base64 image in popover -->
<button type="button" class="btn btn-mini btn-primary" id="imagePopoverButton"      rel="popover">imagePopover</button>

【问题讨论】:

    标签: javascript jquery twitter-bootstrap popover


    【解决方案1】:

    在 cmets 下方添加以下内容

    var image = new Image();
    image.src = "data:image/png;base64," + jqXHR;
    image.id = "image_id";
    image.width = '500';
    image.height = '500';
    $('#imagePopoverButton').html(image);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      • 1970-01-01
      • 2018-02-03
      • 2019-06-25
      相关资源
      最近更新 更多