微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

twitter-bootstrap – Bootstrap 3与远程Modal

我刚刚开始一个新的项目与新的Bootstrap版本:bootstrap 3。
我不能使模态在远程模式下工作。我只是想,当我点击一个链接,它显示模态与远程URL的内容
它工作,但模态布局被完全破坏。

这里是一个jsfiddle链接http://jsfiddle.net/NUCgp/5/

代码

<a data-toggle="modal" href="http://fiddle.jshell.net/Sherbrow/bHmRB/0/show/" data-target="#myModal">Click me !</a>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h4 class="modal-title">Modal title</h4>

            </div>
            <div class="modal-body"><div class="te"></div></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

谁能让这个简单的例子工作?

解决方法

关于模态的远程选项,从 the docs

If a remote URL is provided,content will be loaded via jQuery’s load
method and injected into the root of the modal element.

这意味着你的远程文件应该提供完整的模态结构,而不只是你想要显示在正文上。

Bootstrap 3.1更新:

在v3.1中,上述行为已更改,现在远程内容已加载到.modal-content中

Demo fiddle

Boostrap 3.3更新:

This option is deprecated since v3.3.0 and has been removed in v4. We recommend instead using client-side templating or a data binding framework,or calling 07002 yourself.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐