Friday, June 3, 2011

Re: ClickHandlers and Anchors?

stopPropagation() prevents the event from bubbling any futher up the
DOM tree, I don't want to teach you to suck eggs but:

<table>
<tr>
<td>
<a href="http//www.google.com">Click Me</a>
</td>
</tr>
</table>

Given the above DOM structure if I attach a click event to the table
then click the anchor the event usually bubbles up the DOM tree
calling any event handlers that have been added along the way (this
can be changed to capture event on their way down through the DOM).

If you call stopPropagation() on the Anchor ClickHandler the FlexTable
will never get the click event...if you call stopPropagation() on the
FlexTable the Achor will still call it's ClickHandler and so will the
FlexTable.

If you want to prevent the browser from navigating to the url defined
in the href attribute of the anchor when it gets clicked you need
another method preventDefault();

What you asked was: "Any one have an idea how to detect that the
FlexTable event is actually a click on the anchor"... which wasn't
what you really ment.

:o)

On Jun 3, 2:23 pm, kevin <kalo...@gmail.com> wrote:
> looks like calling event.stopPropagation() in the solution.
>
> On Jun 3, 8:17 am, kevin <kalo...@gmail.com> wrote:
>
>
>
> > I have a Anchor as a cell of a FlexTable. Both the Anchor and the
> > FlexTable have click handlers and as a result, I'm getting two events
> > fired when I click on the anchor. Any one have an idea how to detect
> > that the FlexTable event is actually a click on the anchor?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment