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 51单片机使lcd显示器开机闪烁预设字符闪烁3次需要加什么代码
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal
  • ¥15 想用@vueuse 把项目动态改成深色主题,localStorge里面的vueuse-color-scheme一开始就给我改成了dark,不知道什么原因(相关搜索:背景颜色)
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备
  • ¥100 如何用js写一个游戏云存档
  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题