【问题标题】:Bootstrap3 remote content using PHP使用 PHP 的 Bootstrap3 远程内容
【发布时间】:2014-05-04 07:08:48
【问题描述】:

在 Bootstrap 3 中再次让我大吃一惊。我一直在使用带有模态窗口的 BT3。下面的代码第一次工作并获取远程模式窗口,在我的第二次点击中不起作用。

我查看了以下论坛:

http://www.whiletrue.it/how-to-update-the-content-of-a-modal-in-twitter-bootstrap/

How to show a URL in Bootstrap Modal dialog: On button click

Bootstrap 3 with remote Modal

http://getbootstrap.com/javascript/#modals

来自文档:

如果提供了远程 URL,内容将通过 jQuery 的 load 方法加载一次,并注入 .modal-content div。如果您使用的是 data-api,您也可以使用 href 属性来指定远程源。这方面的一个例子如下所示:

<a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>

index.php

         <a data-toggle="modal" data-target="#myModal" class="btn btn-primary" data-keyboard="false" data-backdrop="false" href="emp_details.php?id=1">Employee 1</a> <a data-toggle="modal" data-target="#myModal" class="btn btn-primary" data-keyboard="false" data-backdrop="false" href="emp_details.php?id=2">Employee 2</a> <a data-toggle="modal" data-target="#myModal" class="btn btn-primary" data-keyboard="false" data-backdrop="false" href="emp_details.php?id=3">Employee 3</a>
        <div class="modal fade" id="myModal">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                <h4 class="modal-title">Test</h4>
              </div>
              <div class="modal-body">Test</div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              </div>
            </div>
          </div>
        </div>

emp_details.php

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
          <h3 id="myModalLabel">Modal header</h3>
        </div>
        <div class="modal-body">
          <?php print_r($_GET); ?>
        </div>
        <div class="modal-footer">
          <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
        

所以现在我的问题是:

  1. 有没有办法在每次点击href时动态获取模态框?
  2. 是否可以动态加载远程内容而不会出现任何问题?

【问题讨论】:

    标签: php twitter-bootstrap twitter-bootstrap-3 modal-dialog


    【解决方案1】:

    哇哇哇.. 我错过了这个答案。

    这真的对我有用。

    Twitter bootstrap remote modal shows same content everytime

    只是你需要添加这个脚本。

     $('body').on('hidden.bs.modal', '.modal', function () {
      $(this).removeData('bs.modal');
     });
    

    再次感谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-10
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      相关资源
      最近更新 更多