douwu8524 2014-01-31 20:58
浏览 18
已采纳

Bootstrap 3交互式远程模态

I've a PHP web application that manage the conversation between two users, recorded in a MySQL database. The conversation is handled by the controller PHP, which stores the messages in the database, and then invokes the PHP template. In this template i've a modal like this:

<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-hidden="true">&times;</button>
    <h4 class="modal-title">Data review</h4>

   </div>
   <div class="modal-body">
      <! -- CONTENT HERE -->
   </div>
   <div class="modal-footer">
     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

   </div>
  </div>
</div>

The modal is opened automatically from the controller index.php, through this:

header('Location: ./#myModal');

And the controller "pass" to the modal, the message text and the sender.

The problem is that every time a user sends a message, the modal disappears and then reappears, with the new message just sent in the conversation. Is it possible to avoid the modal appear and disappear, and that will always remain in the foreground on the page?

Can anyone help me?

Any suggestions will be greatly appreciated :) Thanks!

  • 写回答

1条回答 默认 最新

  • duanliao6789 2014-01-31 21:23
    关注

    If you are reloading the page, you're losing the state. You are going to need to send the messages via AJAX, so you don't have the page reload.

    Without knowing exactly what you're doing, and just trying to solve the problem you are describing, maybe you want have the page reload with the modal already invoked, so it's open at the time of the page load.

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

报告相同问题?

悬赏问题

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