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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:04:16+00:00 2026-05-28T00:04:16+00:00

I am using jquery ui . html : <div id=dialog style=border:1px solid green; width:150px;

  • 0

I am using jquery ui.

html :

<div id="dialog" style="border:1px solid green; width:150px; margin:auto;">

<br />
<div class="dialog_insider" style=" border:1px solid red; width:120px; margin:auto; display:none;">

this is dialog insider
</div><!-- end of id  dialog_insider-->

<br />

</div>

javascript / jquery code snippet:

$(document).ready(function(){

    //$(".dialog_insider", my_dialog).click(function(){

    $(".dialog_insider").click(function(){

        alert("this is an alert box");  
    });

    $("#dialog").click(function(){

        my_dialog=  $(this).clone();
        my_dialog.dialog();

        $(".dialog_insider", my_dialog).css('display','block');
    });
});

Clicking on the dialog box on ‘dialog_insider’ div no longer shows the alert box. To show it there I have to remove the following snippet

$(".dialog_insider").click(function(){

     alert("this is an alert box");  
});

and place it in the following way :

$("#dialog").click(function(){

    my_dialog=  $(this).clone();
    my_dialog.dialog();

    $(".dialog_insider", my_dialog).css('display','block');

    $(".dialog_insider", my_dialog).click(function(){
        alert("this is an alert box");  
    });
});

I know that much. My questions are:

  1. What is the concept of context here that the former coding pattern won’t cover up the ‘dialog_insider’ div on the dialog box?

  2. If the amount of code to be re-written to work in a different context is large, then is there any workaround so that i could easily make the code work in a different context without having to re-write all?

  • 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-28T00:04:17+00:00Added an answer on May 28, 2026 at 12:04 am

    This is because you are creating a new element and inserting it into the DOM via clone(). The ‘click’ handler is not bound to dynamically created elements. You will need to switch to .on( 'click', function() { ... } ); and use delegated events (jQuery >=1.7)

    Here is an updated jsFiddle. Check out the documentation for the on() here.

    Please note that you should

    Avoid excessive use of document or document.body for delegated events on large documents.

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

Sidebar

Related Questions

I am using JQuery I am having below html: HTML Code: <div id=skywardsLogin style=display:
I have a simple html page with a div. I am using jQuery to
I am using a jquery dialog and want to set the .html value with
When i open Jquery dialog in maximized mode using $(window).width() & $(window).height() or $(document).width()
I am using jquery-ui to create a dialog window. the div to be shown
How to remove using jquery html table row after checking checkbox that in this
Using jQuery, I'd like to remove the whitespace and line breaks between HTML tags.
I'm using jQuery to change the HTML of a tag, and the new HTML
I've been using jquery 1.3.2 to pull snippets of html (including script) from a
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render

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.