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 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题