dsa5211314 2014-08-22 15:57
浏览 21
已采纳

从twitter bootstrap模式中加载php页面

I have this modal

    <!-- 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"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Choose Recipients from Address book </h4>
      </div>
      <div class="modal-body">
        <?php echo $output; ?>
      </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>

that i am using to list all blog posts comments.The comments are displayed fine but i now want to view individual comments say comment 1 by clicking the link for that particular comment and load that comment from on the modal.

Upon trying to load that comment,the modal is immediately closing and thus not able to view the comment from within the modal.

Is there a solution that enables me load another php script from within the modal?.

  • 写回答

1条回答 默认 最新

  • dousong4777 2014-08-28 15:41
    关注

    If you want to avoid AJAX, your best option is to put your PHP in a separate file and display it via a frame.

    Another option is to integrate jQuery into your PHP, so that when a link is clicked, display content changes. This is a basic idea of what I mean:

    $(document).ready(function() {
     var e = $('#testModal').find('.modal-body');
     var f = '<a class="comment">Link 1</a>';
     e.html(f);
     $('.comment').click(function() {
      $(this).parent().html('This is your comment.<br /><br /><a class="return">Return</a>');
     });
     $(e).on('click', '.return', function() {
      e = $(this).parent().html(f);
     });
    });
    

    It can be seen working at: http://jsfiddle.net/Lc0vm9o7/

    This is a REALLY basic example. You can utilize PHP to generate as many variables as you would require, to take the load off the clients browser by generating via jQuery.

    I would recommend using the PHP in a frame, though. It would be significantly less messy to not have jQuery thrown throughout your PHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,