[thelist] Javascript : cancel bubble with Safari
Bill Moseley
moseley at hank.org
Wed Feb 15 19:12:59 CST 2006
On Wed, Feb 15, 2006 at 11:02:37PM +0000, Christian Heilmann wrote:
> What is this behaviour thing you talk about?
http://bennolan.com/behaviour/
It basically provides a way to find elements by CSS selector.
> I cannot quite follow what you are trying to do... cancelClick
> actually makes sure the link is not followed but Safari does neither
> get cancelBubble nor stopPropagation properly.
Oh. No, I have a table and I want to allow clicking on any part of
the row and follow a link. Hence the onclick on the <tr>.
But, I also have a few <a> links inside the row, so when those are
clicked I don't want the outer <tr> onclick to *also* run. That's
what the cancel bubble is all about.
In my original post this assigned an onclick to all the <a> inside
the <td> inside the tables.
'#matrix td a' : function(e){
e.onclick = function(e){
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return true;
}
}
For some reason that was not working with Safari. It was making the
<a> links not do anything.
Changing to addEvent fixes it, but I don't understand why that works
differently than the above. Although, if it's a bug in Safari
there's nothing to really understand. It's just a bug. ;)
'#matrix td a' : function(e){
addEvent(e, 'click', stop_bubble, false );
e.onclick = function() { return true; }
}
Thanks,
--
Bill Moseley
moseley at hank.org
More information about the thelist
mailing list