twitter-bootstrap - Bootstrap 3 与远程 Modal

标签 twitter-bootstrap modal-dialog

我刚刚使用新的 Twitter Bootstrap 版本启动了一个新项目:bootstrap 3。 我无法使 Modal 在远程模式下工作。我只是希望当我单击链接时,它会显示带有远程 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 jQuery.load yourself.

关于twitter-bootstrap - Bootstrap 3 与远程 Modal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18378720/

相关文章:

javascript - AngularJS bootstrap popover 自定义指令

jquery - Bootstrap 选项卡不添加事件类链接

Android 开始模态 Activity

ios - 防止关闭模态 WKInterfaceController

html - 响应式 Bootstrap 网格中内容的垂直和水平居中

ruby-on-rails - 使用 Twitter Bootstrap 设计 Rails 按钮链接助手

twitter-bootstrap - 在 Bootstrap 模式中捕获 Firebase 错误

internet-explorer-8 - 如何在IE8中更改Bootstrap 3模式的宽度?

javascript - 单击回复按钮后,我想填充引导模式中的表列

javascript - 从用户控件内部关闭 jQuery 对话框