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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:40:08+00:00 2026-05-14T03:40:08+00:00

I’ve run into the problem that has been addressed here without a workaround: I

  • 0

I’ve run into the problem that has been addressed here without a workaround: I can’t use stopPropagation() on dynamically spawned elements.

I’ve tried creating a condition to exclude a click within the dimensions of the spawned element, but that doesn’t seem to work at all.

Here is what I got:

1) a large background element (“canvas”) that is activated to be “sensitive to clicks on it” by a button

2) the canvas, if activated, catches all clicks on it and spawns a small child form (“child”) within it

3) the child is positioned relative to the mouse click position. If the mouse click was on the right half of the canvas, the child will be positioned 200 pixels to the left of that spot. (On the right if the click was in the left half)

4) every new click on the canvas removes the existing child (if any) and spawns a new child at the new position (relative to the click)

The problem: Since the spawned child element is on top of the canvas, a click on it counts as a click on the canvas. Even if the child is outside of the boundaries of the canvas, clicking on it will trigger the action as described in 4) again . This shouldn’t happen.

=========== CODE:
The button to activate the canvas:

$('a#activate').click(function(event){
    event.preventDefault();
    canvasActive(); 
});

I referenced the above to show you that the canvas click-catching is happening in a function. Not sure if this is relevant…

This is the function that catches clicks on the canvas:

function canvasActive() {
    $('#canvas').click(function(e){
        e.preventDefault();

        //get click position relative to canvas
        posClick = {
            x : Math.round(e.pageX - $(this).offset().left),
            y : Math.round(e.pageY - $(this).offset().top)
        };

        //calculate child position
        if(posClick.x <= $canvas.outerWidth(false)/2) {
            posChild = {
                x: posClick.x + 200, //if dot is on the left side of canvas
                y: posClick.y
            };
        } else {
            posChild = {
                x: posClick.x - 600, //if dot is on the right
                y: posClick.y
            };
        }

        $(this).append(markup); //markup is just the HTML for the child

    });
}

I left out the unimportant stuff. The question is:

How can I prevent a click inside of a spawned child from executing the function? I tried getting the child’s dimensions and doing something like “if posClick is within this range, don’t do anything” – but I can’t seem to get it right.

Perhaps someone has come across this dilemma before. Any help is appreciated.

  • 1 1 Answer
  • 1 View
  • 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-14T03:40:08+00:00Added an answer on May 14, 2026 at 3:40 am

    I don’t actually see any jQuery .live() code. Regular events added with bind, click, etc. are not “live” events.

    In any case, all you need to do here is check the item that was passed into the event to see if it’s the canvas:

    $('#canvas').click(function(e){
        if($(this).is('#canvas')){
          // it really was the canvas that was clicked!
          // could also check "e.currentTarget"--it's the same as "this"
          // do your thing and return false
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

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.