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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:29:38+00:00 2026-06-12T18:29:38+00:00

This is a reformulated question from the original posted here I have a page

  • 0

This is a reformulated question from the original posted here

I have a page with a jQuery UI Dialog, and I open Fancybox from a link inside of such Dialog window.

The typical UI Dialog init is like:

 $("#dialog-modal").dialog({
  height: 240,
  modal: true
 }); // dialog

… and the typical Fancybox (v2.1.1 in this example) init like:

 $(".fancybox").fancybox({
  closeClick: false,
  helpers: {  
   title : { type : 'inside' }
  }
 }); // fancybox

… so far so good, nothing special. Then the html :

 <div id="dialog-modal" title="jQuery UI modal dialog">
  <p>You should be able to close this UI Dialog using the "escape" key.</p><br />
  <a class="fancybox" href="images/01.jpg" title="Press the 'escape' key to close Fancybox" >Open Fancybox</a>
 </div>

Now, the issue is, if I close Fancybox using the “escape” key, both Fancybox AND the UI Dialog (from where I launched fancybox) are closed.

Both Fancybox and UI Dialog can be closed using the escape key but ideally I would like to keep the UI Dialog opened after closing Fancybox (with the escape key) … if close Fancybox with the close button for instance, the UI Dialog remains opened.

To illustrate the issue, I created a DEMO here.

So how can I close Fancybox using the escape key without closing the UI Dialog from where I opened Fancybox?

  • 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-12T18:29:39+00:00Added an answer on June 12, 2026 at 6:29 pm

    The solution :

    Disable the escape event in both Fancybox and the UI Dialog and catch any escape event to close manually either Fancybox (if opened) or the UI Dialog otherwise.

    In order to avoid to be closed pressing the escape key, both plugins offer an API option … so for the UI Dialog add the closeOnEscape option set to false like :

    $("#dialog-modal").dialog({
        height: 240,
        modal: true,
        closeOnEscape: false // disable escape event on dialog
    }); // dialog
    

    … for Fancybox use the keys API option like :

    $(".fancybox").fancybox({
        closeClick: false,
        helpers: {
            title: {
                type: 'inside'
            }
        },
        keys: {
            close: [null] // disable escape on fancybox
        }
    }); // fancybox
    

    … then catch the document’s escape event ( using jQuery .keyup() ) and close manually Fancybox (if opened) or the UI Dialog otherwise with this function:

    $(document).keyup(function (event) {
        if (event.keyCode === 27) {
            // if fancybox is opened, close it, otherwise close dialog
            if ($.fancybox.isActive) {
                $.fancybox.close();
            } else {
                $("#dialog-modal").dialog("close");
            }
        }
    }); //keyup
    

    See working DEMO and feel free to explore the source code.

    Tested in Chrome v22.0.1229.94 m, Firefox v16.0.1, IE7+, Opera v11.61(1250) and Safari (Windows) v5.1.7(7534.57.2)

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

Sidebar

Related Questions

this is my first question in here, and I would like to ask if
this is a rephrasing of a question I posted yesterday. I got an answer
I have a request spec that looks like this: describe Registering from the main
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
This should be a simple one: I have an observableArray object called To in
This seems like a very simple question, so I will remove if it's a
This is a very newbie question I fear... I was wondering if there are
This is a follow up to a question: KnockoutJS Sortable group observableArray by field
this is the error log i am getting i have highlighted the error also

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.