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 8964601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:37:35+00:00 2026-06-15T16:37:35+00:00

I’m working on a landing page for my web app, and I’m using some

  • 0

I’m working on a landing page for my web app, and I’m using some sort of modal boxes I built.
It uses some jQuery to display the box itself and the overlay.
There are 3 modal boxes on the same page that you can open with one link for each box.

My code works really well (even though it seems heavy [I’m not a pro in Javascript but I always give a try as much as I can]). But when I close the modal box, the overlay slides out as it’s supposed to do but the animation repeats 3 times (probably because of the code for the 3 modal box).

So, my code is fully online there → http://graphix.net23.net/app/

Here’s the jsFiddle for you to play 🙂 → http://jsfiddle.net/EY59T/ (the bug isn’t really visible, you can only see the overlay takes a while to get away)

I already tried the .stop() function. It solves the problem when you display the first modal, but after when you click on another modal, the overlay doesn’t come.

Look at my heavy code:

// iOS Modal
$("a#modal-open").click(function () {
      $("div#modal-ios").show("fade", 600);
      $("div.modal-overlay").show("slide", 300);
      $(".app h4").hide("fade", 300);
      $("div.app").animate({backgroundPositionY:-120}, 600);
      return false;
});
$("a#modal-done,div.modal-overlay").click(function () {
      $("div#modal-ios").hide("fade", 600);
      $("div.modal-overlay").hide("slide", 300);
      $(".app h4").show("fade", 600);
      $("div.app").animate({backgroundPositionY:0}, 600);
      return false;
});
$( document ).on( 'keydown', function ( e ) {
    if ( e.keyCode === 27 ) {
        $("div#modal-ios,div.modal-overlay").hide("fade", 300);
        $(".app h4").show("fade", 300);
        $("div.app").animate({backgroundPositionY:0}, 600);
    }
});
// END iOS Modal
// Android Modal
$("a#modal-open-android").click(function () {
      $("div#modal-android").show("fade", 600);
      $("div.modal-overlay").show("slide", 300);
      return false;
});
$("a#modal-done,div.modal-overlay").click(function () {
      $("div#modal-android").hide("fade", 600);
      $("div.modal-overlay").hide("slide", 300);
      return false;
});
$( document ).on( 'keydown', function ( e ) {
    if ( e.keyCode === 27 ) {
        $("div#modal-android,div.modal-overlay").hide("fade", 300);
    }
});
// END Android Modal
// WP Modal
$("a#modal-open-wp").click(function () {
      $("div#modal-wp").show("fade", 600);
      $("div.modal-overlay").show("slide", 300);
      return false;
});
$("a#modal-done,div.modal-overlay").click(function () {
      $("div#modal-wp").hide("fade", 600);
      $("div.modal-overlay").hide("slide", 300);
      return false;
});
$( document ).on( 'keydown', function ( e ) {
    if ( e.keyCode === 27 ) {
        $("div#modal-wp,div.modal-overlay").hide("fade", 300);
    }
});
// END WP Modal​

It’s been two days I’m working on it and still can’t find a working solution, help me please 🙂

EDIT: you can close the modal with three different ways: click on button, click on overlay or ESC key. Note that the bug doesn’t happen with the ESC key.

  • 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-15T16:37:35+00:00Added an answer on June 15, 2026 at 4:37 pm

    The problem is that you are binding the closing handlers three times one for each type of model you open. but you bind those on the same elements a#modal-done,div.modal-overlay. This way when you click on it, it starts 3 fades on the same elements and that messes it up.

    You need to apply the handler only once, and just add the fading of all popups in there..

    Also by adding a common class to your links that are for opening the popups, you can target those in a single pass as well

    These will simplify your code to

    // method to hide any open popup and the overlay
    function closePopupOverlay() {
        // hide all popups - will only really work with the currently open one
        $("#modal-ios,#modal-wp,#modal-android,div.modal-overlay").hide("fade", 500);
    
        $(".app h4").show("fade", 500);
        $("div.app").animate({
            backgroundPositionY: 0
        }, 600);
    }
    $(document).on('keydown', function(e) {
        if (e.keyCode === 27) {
            closePopupOverlay();
        }
    });
    $("a#modal-done,div.modal-overlay").click(function() {
        closePopupOverlay();
        return false;
    });
    // when we click on one of the links 
    $('.model-open').click(function() {
        var target = this.id.replace('-open-', '-'); // find the related popup id
        $('#' + target).show("fade", 600); // show the related popup
        $("div.modal-overlay").show("slide", 300); // show the overlay
    
        if (target === 'modal-ios') { // handle the special needs of the ios button
            $(".app h4").hide("fade", 300);
            $("div.app").animate({
                backgroundPositionY: -120
            }, 600);
        }
    
        return false;
    });
    

    The html change is that i added class="model-open" to your 3 links and also changed the id for the ios link to modal-open-ios to conform with the other two, so we can easily extract what popup we want to open..

    Demo at http://jsfiddle.net/EY59T/1/

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.