Closing modal when user sign up or login

31 views
Skip to first unread message

Muhammed Tüfekyapan

unread,
Oct 8, 2014, 6:21:39 PM10/8/14
to django...@googlegroups.com
Hello everyone,


I have a form. All users see this form. My needs is like this;
- If user logged in, save their settings.
- If user doesn't logged in, first show him a modal
- If he login or sign up, close modal and save their settings. (settings shouldn't be lost.)


For now my template looks like this;

...
{% if request.user.is_authenticated %}
<form action="/socials/create/{{ link_id }}/" method="post">
{% csrf_token %}
    {{ form }}

###form fields

<input type="submit" value="Create"> </p>
</form>
{% else %}
<p>Henüz üye girişi yapmadınız yada üye değilsiniz!</p>
    <form action="/socials/create/{{ link_id }}/" method="post">
      {% csrf_token %}
        {{ form }}

###form fields

    </form>
      <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Create</button>


              <!-- 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">Welcome</h4>
                    </div>
                    <div class="modal-body">
                      <p>In order to save your changes, you have to login or sign up!</p>
                      <a href="/accounts/facebook/login/" target="_blank">Login with Facebook</a>
                    </div>
                    <div class="modal-footer">

                      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                  </div>
                </div>
              </div>
<!-- Button trigger modal -->

{% endif %}
...

How can i do that?

Collin Anderson

unread,
Oct 13, 2014, 2:52:05 PM10/13/14
to django...@googlegroups.com
Hello,

You probably need to use some sort of ajax for that.

Collin

Reply all
Reply to author
Forward
0 new messages