Javascript twitter引导模式不显示远程映像

Javascript twitter引导模式不显示远程映像,javascript,ajax,twitter-bootstrap,modal-dialog,Javascript,Ajax,Twitter Bootstrap,Modal Dialog,我正在使用twitter引导的模式窗口加载远程映像 <a href="assets/500x300.gif" data-target="#image-preview" data-toggle="modal"><img alt="250x150" src="/assets/250x150.gif"></a> 我是 图像在模式中未正确渲染 我得到了一堆乱七八糟的数据- 发生了什么事?如何修复?使用href为模式指定远程内容时,Bootstrap使用jQue

我正在使用twitter引导的模式窗口加载远程映像

<a href="assets/500x300.gif" data-target="#image-preview" data-toggle="modal"><img alt="250x150" src="/assets/250x150.gif"></a>

我是

图像在模式中未正确渲染

我得到了一堆乱七八糟的数据-


发生了什么事?如何修复?

使用href为模式指定远程内容时,Bootstrap使用jQuery的load方法获取内容,然后将检索到的内容粘贴到模式的body元素中。简而言之,只有当远程内容(href值)加载HTML或文本时,它才有意义

您看到的是预期的,因为如果您在文本编辑器中打开gif文件,并将其粘贴到HTML标记中,也会发生同样的情况


要使其按您想要的方式工作,href需要指向一个HTML文档,该文档包含一个引用您希望在模式中显示的图像的标记。

是的,我也有这个。我找到的答案是

我创建了如下链接:

<a href="gallery/blue.jpg" class="thumbnail img_modal">

//handler for link
$('.img_modal').on('click', function(e) {
    e.preventDefault();
    $("#modal_img_target").attr("src", this);
    $('#modal').modal('show');
});

//and modal code here

<div id="modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Title to go here</h3>
    </div>
    <div class="modal-body">
        <img id="modal_img_target">
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    </div>
</div>

//链接处理程序
$('.img_modal')。在('click',函数(e)上{
e、 预防默认值();
美元(“#模态img_目标”).attr(“src”,本);
$('#model')。model('show');
});
//这里是模态代码
×
这里的头衔
接近

在马克·罗布森的帖子中–将“this”改为“this.href”:


$(“#modal#img_target”).attr(“src”,this)