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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:20:43+00:00 2026-05-21T22:20:43+00:00

I have the following scenario: A button opens a modal dialog which contains a

  • 0

I have the following scenario:

A button opens a modal dialog which contains a checkbox. When I click on this checkbox, I want another modal dialog (a warning) to be displayed, but I also want to keep the new checkbox state (either checked or unchecked). For example, if the checkbox is unchecked and is clicked on, I expect the warning to be displayed and the checkbox to become checked.

The first part (opening a modal dialog over an existing modal dialog) is working correctly, but the second part isn’t (the checkbox never becomes checked). To be honest, while debugging I noticed the checkbox actually does become checked during event handling, but for some reason which I was unable to determine, it is reverted back to its original state.

I also noticed that the revert problem doesn’t happen if I have a select field or a radio button instead of a checkbox, and it also doesn’t happen if either dialog is not modal.

Here’s my code (demo: http://jsbin.com/amiyu4/2):

$(document).ready(function() {
  $('#myButton').button();

  $('#myButton').click(function() {
    var $dialog = $('<div><input type="checkbox" id="myCheckbox"/> <label for="myCheckbox">Show warning</label></div>');
    $dialog.dialog({
      modal: true,
      title: 'Modal dialog',
      buttons: {
        'Ok': function() {
          $(this).dialog('close');
        }
      },
      width: 600
    });

    $dialog.find('#myCheckbox').change(function() {
      var $alert = $('<div>Warning!</div>');
      $alert.dialog({
        autoOpen: true,
        modal: true,
        title: 'Warning',
        buttons: {
          'Ok': function() {
            $(this).dialog('close');
          }
        }
      });
    });

    $dialog.dialog('open');
  });
});

My actual questions are:

1) Why doesn’t the checkbox ever become checked?

2) What can I do to make it both become checked and display the warning?

EDIT: I forgot to mention: this was tested in Chrome. In Firefox the code above works. In Internet Explorer it fails.

  • 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-21T22:20:44+00:00Added an answer on May 21, 2026 at 10:20 pm

    I’ll answer your questions:

    1) Why doesn’t the checkbox ever
    become checked?

    There’s a jquery-ui bug related to this with that happens only in IE, related to execution order. If you run your code in other browsers, it’ll do fine.

    2) What can I do to make it both
    become checked and display the
    warning?

    You should add a small delay when clicking the checkbox. So you’ll have:

    $dialog.find('#myCheckbox').change(function() {
          setTimeout(function(){  //This does the trick!!
            var $alert = $('<div>Now it works!!</div>');
              $alert.dialog({
                autoOpen: true,
                modal: true,
                title: 'Warning',
                buttons: {
                  'Ok': function() {
                    $(this).dialog('close');
                  }
                }
            });
          }, 10);
        });
    

    I tested it and it works as expected.
    Hope this helps.
    Cheers

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

Sidebar

Related Questions

How could I best implement the following scenario? I have a Next Period... button
I have the following scenario where I want to pass in string and a
Following Scenario: I have a = UIViewController A that contains a UIScrollView I have
For the following scenario: I have an ASP.NET FileUpload control and a Button that
I have one scenario where I want to change order of click events attached
This is a little weird. I have the following scenario: A page containing a
I have the following simple scenario: A DialogForm with a Button, the Button_click throws
This might be a novice question. :). Consider the following scenario. Suppose we have
I have the following scenario. I have a search page which is split into
I have the following scenario I have a main form as MDI parent and

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.