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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:31:11+00:00 2026-05-24T20:31:11+00:00

In jQuery-UI-Dialog allows me to display a ‘modal’ dialog box on my web page

  • 0

In jQuery-UI-Dialog allows me to display a ‘modal’ dialog box on my web page so that the user must click an option in the dialog to proceed.

I’ve been writing my own dialog box code, but there is something that jQuery-UI-Dialog does that I don’t know how to do yet.

I am able to display a “mask” element behind the dialog to prevent the user from clicking on elements on the page, but the user can still select elements behind the dialog using the tab key.

The jQuery-UI-Dialog seems to somehow trap the keyboard input inside the dialog box even when the tab key is pressed. This is very neat, but I will add that it could be abused.

What aspect of the DOM do I need to access to get this 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-05-24T20:31:13+00:00Added an answer on May 24, 2026 at 8:31 pm

    I would like to accept William Niu’s answer, but there is a flaw that prevents it from working in my web application. If the first or last element in the dialog is a radio button, then this code won’t work in IE. The browser will tab to the radio button group one time.

    If the selected radio button is one that the browser highlights when the user tabs to the radio button group, then this code will work. However, the selected radio button is not the one the browser highlights when the user tabs to the radio button group, then the focus will be lost from the dialog.

    Here is some code I’ve written that solves this problem:

    function _bindTabKeyForDialog(dialogId) {
        var tabbable = $('#' + dialogId).find(':tabbable');
        var firstElement = $(tabbable).filter(':first');
        var lastElement = $(tabbable).filter(':last');
    
        var firstGroup = (firstElement[0].type !== 'radio') ?
            firstElement :
            tabbable.filter("[name='" + firstElement[0].name + "']");
        var lastGroup = (lastElement[0].type !== 'radio') ?
            lastElement :
            tabbable.filter("[name='" + lastElement[0].name + "']");
    
        $(document).unbind('keydown.' + dialogId);
        $(document).bind('keydown.' + dialogId, function (e) {
            if (e.keyCode == 9) {
                if ($(e.target).is(lastGroup) && !e.shiftKey) {
                    firstGroup.first().focus();
                    e.preventDefault();
                }
                else if ($(e.target).is(firstGroup) && e.shiftKey) {
                    lastGroup.first().focus();
                    e.preventDefault();
                }
            }
        });
    } // end _bindTabKeyForDialog
    

    As you can see, I change William’s first and last variables to groups of elements. If the first or last tabbable element in the dialog is a radio button, then it will include all radio buttons with the same name.

    Otherwise, this code functions the same as William’s code.

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

Sidebar

Related Questions

I have a jQuery dialog that pops up and allows the user to send
I have a jQuery dialog that appears and loads an external page. In that
I am using the jQuery dialog widget with the modal option over a wordpress
I have a quick edit jquery dialog that allows my users to change some
Consider the following scenario: I have a page that can open a dialog (jquery
I have a jQuery dialog that requires the user to enter certain information. In
I have a jquery dialog box that opens by means of a link. I
I built a custom Message Dialog Box JQuery plugin that works great. However, I
I am using Jquery Dialog box for a cv registration form on my website
I have a jQuery dialog which loads an external php page. All is working

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.