tags:

views:

41

answers:

2

Hello, here's the situation: I have a where in every cell all the area has a onclick event that opens a edit form, let's call this A. In the same cell, in a corner I also have an 'X' to delete the object represented in that cell, also with an onclick event in this case with a Yes/No warning, let's call this B.

When I click on the X (onclick B), it appears de dialog to confirm I want to delete or not but the problem comes whatever I trigger, I also run the onclick A because B is in the same onclick area that A.

Is there any solution so when I click on B, A does not trigger? Hope I make clear my problem.

Thanks

Update

Thanks to the guide http://www.quirksmode.org/js/events_order.html I just had to add this JS function

function doSomething(e)
{
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}

And call it on the onclick B event before calling my other function:

onclick="doSomething(); Calendar.delClick('${id}', this); return false"

Thank you both very much ;)

+4  A: 

Use event bubbling

N 1.1
Thanks going for that reading
framara
btw quirksmode.org is an excellent guide to javascript.
N 1.1
+2  A: 

I think what you experiencing is event bubbling. Have a look at PPKs excellent writing in this matter.

anddoutoi
Specifically this section: http://www.quirksmode.org/js/events_order.html#link9 (and note that most libraries will implement an abstraction for you, e.g. http://developer.yahoo.com/yui/3/api/DOMEventFacade.html#method_halt )
David Dorward
Yeah, bugger you beat me with 20 sec ^^ +1 upvote from me to you it is.
anddoutoi
are you serious? :D
N 1.1