Flask Bootstrap modal works on dev server, but not

2019-08-17 02:37发布

问题:

Does anyone face this issue.. I have a very strange behavior with Flask and Bootstrap modal. On my dev server http://127.0.0.1:5000/ I have a modal which appears after user is typing wrong login credentials:

HTML code in Index page:

<div class="modal fade" id="ExistsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">This email already exists!</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              If you have forgotten your password, .......
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Continue</button>

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

But on my production 'http://flask-env.xxx.us-west-1.elasticbeanstalk.com I can see the modal only if I manually refresh a page!

For return function I'm using return redirect(url_for('index',_anchor='login')) and in index() I passed arguments!

{% if email_exists %}
          <script>
            $("#ExistsModal").modal('show');
          </script>
          {% endif %}

My question is - why modal show up after manual refresh on production? But on dev its works fine!