如何通过bootstrap模式动态加载html内容

时间:2016-08-23 11:12:13

标签: twitter-bootstrap bootstrap-modal

我看过这个示例代码,但它无法正常工作。只是指导我无法将数据加载到模态的代码中出现了什么问题。我也关注此链接http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=modal-with-remote-url

代码在这里

<a href="http://tutsme-webdesign.info/bootstrap-3-modal-displaying-remote-content/" data-toggle="modal" data-target="#myModal" data-remote="false" class="btn btn-default">
    Launch Modal
</a>

<!-- Default bootstrap modal example -->
<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-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </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>
  </div>
</div>


$("#myModal").on("show.bs.modal", function(e) {
        //alert(e.relatedTarget);
    var link = $(e.relatedTarget);
    $(this).find(".modal-body").load(link.attr("href"));
});

小提琴链接https://jsfiddle.net/tridip/L8fr0u28/

0 个答案:

没有答案