Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:59:45+00:00 2026-06-07T00:59:45+00:00

I have a modal containing a carousel with 2 slides with login and signup

  • 0

I have a modal containing a carousel with 2 slides with login and signup forms.

I want to achieve the following:

  • When user clicks a “Login” link in site header, the modal should open
    and carousel should slide to the “login” slide (it’s at the index of
    0).
  • When user clicks a “Signup” link in site header, the modal should
    open and carousel should slide to the “signup” slide (it’s at the
    index of 1)
  • Whenever a slide transition occures, the modal title text
    is changed (binding to the “slid” event of the carousel)

However, I cannot seemt to get this to work. I think the problem is with the order of how all these events happen.

Here’s the basic code:

// Initialize modal
$('.modal').modal()

// Initialize carousel
$('.carousel').carousel()
$('.carousel').carousel('pause') // Pause the carousel so it doesn't auto-rotate

$('.signuplink').on('click', function() {
    $('.carousel').carousel(1).on('slid', function() {
        $('.modal .modal-title').html('Sign Up');
        $('.modal').modal('show');
    });
});

But it does not work. The “slid” event never occures when the modal is not shown beforehand. So I tried to show the modal and then slide the carousel, binding to the “shown” event of the modal, but while it does slide to the next slide, the “slid” event does not occur.
What is even more weird, is that the close button on the modal does not work anymore, like all event handling is messed up…

EDIT: It seems that the “shown” event is not fired when the modal is being shown the first time. It fires only when I hide the modal. When I open it again, “shown” seems to be fired on the correct moment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:59:47+00:00Added an answer on June 7, 2026 at 12:59 am

    First of all, there is too much nesting.

    You should almost never nest event binding inside a click event – or any event – because you will add another listener each time you click.

    This is a solution.

    var $myModal = $('#myModal').modal({show: false});
    var $myCarousel = $('#myCarousel').carousel({'interval': false});
    
    $('.btn').each(function() {
        var $this = $(this);
        var index = $(this).date('slide-index');
        $this.click(function() {
            $myModal.modal('show');
            $myCarousel.carousel(index);
        });
    });
    
    <button class="btn" data-slide-index="0">0</button>
    <button class="btn" data-slide-index="1">1</button>
    
    <div id="myModal" class="modal fade">
        <div id="myCarousel" class="carousel">
            <div class="carousel-inner">
                <div class="active item">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">×</button>
                        <h3>Title 0</h3>
                    </div>
                    <div class="modal-body">
                        <p>0</p>
                    </div>
                </div>
                <div class="item">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">×</button>
                        <h3>Title 1</h3>
                    </div>
                    <div class="modal-body">
                        <p>1</p>
                    </div>
                </div>
            </div>
            <!-- Carousel nav -->
            <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
            <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
        </div>
    </div>
    

    Live Demo (jsfiddle)

    But there is still a bug if you activate the sliding effect : the Carousel object keep sliding: true after a few slidings – thus blocking future slidings ; improvement welcome.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: User clicks a link, a modal window is displayed containing one big
I'm trying to have some modal dialogs show up containing the forms, without going
I have a modal view controller, and I want its navigation bar (I think
I have a modal dialog box which is containing search field. when I select
I have a jQuery UI Dialog containing some checkboxes. I want to conditionally set
I have a modal dialog containing a JLabel. This dialog calls a method in
I have a model containing ImageField which should be resized after uploading. class SomeModel(models.Model):
I have a simple model containing a FileField among others. When I use a
I have an old Xcode project which contains a CoreData model (containing a version
I have a model for assessment criteria which has a :label field containing string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.