So I have a parent that defines a onmouseup event that hide/display a table. The problem is that I want the ability to have nested expandable/collapsible tables but when I click one that is nested it will fire the event for the parent and collapse everything. I can do some niffy stuffy in javascript like assume that the nested event will fire first and then cancel the parent event but that seems kind of hacky. Is there a way to declare from a child element that no parent elements should fire for this event?
+1
A:
I don't think you can declare that kind of thing on an element but you could, as you implied, try inside the handler of the child:
e.stopPropagation()
where e is the event ? or return false; should have the same effect, but I seem to remember having an issue (perhaps IE where it didn't work, but that could just be another factor I was missing)
David Archer
2009-07-07 14:00:03
Returning false prevents the default behavior from executing (e.g. clicking a submit button inside a form). Good solution, but I don't think returning false has anything to do with what he's looking for. +1
Lior Cohen
2009-07-07 15:12:40
A:
Could you possibly iterate through all the parents and re-define their onMouseUp
property to do nothing?
Topher Fangio
2009-07-07 14:03:26