Event capturing/bubbling problem

P

Piotr K

Hi,

I ran out of ideas how to solve this problem, maybe someone of you
will help me.. Situation goes like this: I have two elements on site
which are siblings, both of them have "onclick" event. On of these
elements has "position: absolute" and is covering the second element.
What I want to achieve, is when user clicks on the absolute positioned
element, "onclick" event fires for both elements. I tried just
everything that camed to my mind, but wihtout result. Anyone got an
idea how to achieve this? Or is it just impossible to make?

Thanks for any help,
Piotr.
 
D

David Mark

Hi,

I ran out of ideas how to solve this problem, maybe someone of you
will help me.. Situation goes like this: I have two elements on site
which are siblings, both of them have "onclick" event. On of these
elements has "position: absolute" and is covering the second element.
What I want to achieve, is when user clicks on the absolute positioned
element, "onclick" event fires for both elements. I tried just

Why don't you just call the onclick handler for the overlapped element
from the positioned element's onclick handler?
everything that camed to my mind, but wihtout result. Anyone got an
idea how to achieve this? Or is it just impossible to make?

I don't understand what you are trying to make.
 
R

RobG

Hi,

I ran out of ideas how to solve this problem, maybe someone of you
will help me.. Situation goes like this: I have two elements on site
which are siblings, both of them have "onclick" event. On of these
elements has "position: absolute" and is covering the second element.
What I want to achieve, is when user clicks on the absolute positioned
element, "onclick" event fires for both elements. I tried just
everything that camed to my mind, but wihtout result. Anyone got an
idea how to achieve this? Or is it just impossible to make?

Not impossible, as David has suggested. Events bubble up or capture
down the DOM tree, the siblings of the element that starts the event
(or that are higher up the DOM tree) will never be involved in either
sequence. At least one major browser doesn't support the capture
phase anyway.
 
P

Piotr K

Why don't you just call the onclick handler for the overlapped element
from the positioned element's onclick handler?




I don't understand what you are trying to make.

Well, it was just an example, that absolute positioned element won't
always entirely cover the second element. What I'm making is
drag'n'drop feature with containers where you can drop dragged
elements. Currently I'm checking if element is dragged above container
at global onmousemove event (by checking if mouse position is in
container boundaries), but it isn't too efficient. It would be much
faster and more accurate if mouse events would fire also for elements
under the dragged element.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top