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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:32:48+00:00 2026-06-18T00:32:48+00:00

Here is my problem. I have some custom jquery written to toggle down a

  • 0

Here is my problem. I have some custom jquery written to toggle down a login form on my site. I then added some code I found here to close that box if you click off it.

The problem comes in because I have a link to a fancybox inside this div that toggles in/out. Because i’m using event.stopPropagation(); along with the clickoff, it messes with that fancybox link. Full code example is below.

//Login Toggle
    $('a.login').click(function() {
        if ($('.login-box').is(':hidden')){
            $('.login-box').fadeIn('normal');
            $('span.arrow-up').fadeIn('normal');
            $(this).text('Close');
        }
        else{
            $('.login-box').fadeOut('normal');
            $('span.arrow-up').fadeOut('normal');
            $(this).text('Log-In');
        }
    });
    //Close when click off login
    $('html').click(function() {
        $('.login-box').fadeOut('normal');
        $('span.arrow-up').fadeOut('normal');
        $('a.login').text('Log-In');
    });
    //Exclude these divs, so clicking inside them won't close login
    $('.login-box, a.login, span.arrow-up').click(function(event){
        event.stopPropagation();
    });

    //Forgot Password Fancybox
    $("a.fancybox").fancybox({
        maxWidth    : 800,
        maxHeight   : 600,
        fitToView   : false,
        width       : '70%',
        height      : '70%',
        autoSize    : false,
        closeClick  : false,
        openEffect  : 'fade',
        closeEffect : 'fade'
    });

If I take out the stopPropagation, everything works as expected (the fancybox button works), I just lose the ability to close the login box by clicking outside of it. Can anyone help me with a smarter way of writing it that doesn’t break the fancybox functionality?

  • 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-18T00:32:49+00:00Added an answer on June 18, 2026 at 12:32 am

    event.stopPropagation() is preventing the event from reaching the handler that is set by fancybox

    You need to allow events targeting a.fancybox to continue propagating

    $('.login-box, a.login, span.arrow-up').click(function(event){
        if ($(event.target).hasClass('fancybox') == false) {
            event.stopPropagation();
        }
    });
    

    This will allow events to propagate for any elements that have the class ‘fancybox’


    This is unrelated to your problem, but I would suggest that you add event.preventDefault() or return false to click handlers for links

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

Sidebar

Related Questions

So I have a problem here. I have set some custom styles for a
I have a form with jquery validation. I have some custom rules, but they
i have some trouble with the custom shapes in corona. Here is my code
So here is the problem: I have some logic in my application that will
Updated Problem solved, I have some design problem here. The directory looks like that:
I have some problem with my .htaccess file. Here I am adding my problem.
Here's a problem. Developers have some kind of a task (develop certain feature), which
I have some problem to order an array by a field of this, here
I have a problem with an image that I am applying a custom jquery
I have been working on a custom image slider featured here: JQuery $(function(){ $('.cont:gt(0)').hide();

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.