Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

mohammed mayat
mohammed mayat
4,228 Points

multiple modal

i want to create two modal in the same page, i can only create one modal per page, i wanted to have registartion and login in two diffrent modal how do i do this

1 Answer

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

Here is an example of how I did it using bootstrap4 - I used their modal template and then I just change the ID's

        <a href="#" class="text-dark" data-toggle="modal" data-target="#loginModal"><u>Login</u></a> or
        <a href="#" class="text-dark" data-toggle="modal" data-target="#signupModal"><u>Sign up</u></a> to create a comment

        <!-- Login Modal -->
        <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header bg-info">
                        <h5 class="modal-title text-white" id="loginModalLabel">Login</h5>
                        <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body p-5">
                        <form action="{% url 'users:login' %}" method="POST" class="col-12 col-md-8 mx-auto">
                            {% csrf_token %}
                            {% bootstrap_form login_form %}
                            {% bootstrap_button 'Login' button_type='submit' button_class='btn-info btn-block mt-3' %}
                            <input type="hidden" name="next" value="{{ request.get_full_path }}">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <!-- Sign up Modal -->
        <div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-labelledby="signupModalLabel" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header bg-info">
                        <h5 class="modal-title text-white" id="signupModalLabel">Sign up</h5>
                        <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body p-5">
                        <form action="{% url 'users:signup' %}" method="POST" class="col-12 col-md-8 mx-auto">
                            {% csrf_token %}
                            {% bootstrap_form signup_form %}
                            {% bootstrap_button 'Sign up' button_type='submit' button_class='btn-info btn-block mt-3' %}
                            <input type="hidden" name="next" value="{{ request.get_full_path }}">
                        </form>
                    </div>
                </div>
            </div>
        </div>