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 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解