The onBrowserEvent method of an abstract cell returns a parent element. If I have multiple HTML items rendered within the cell, such as spans or divs, how do I get and distinguish which one triggered the event?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
NativeEvent#getEventTarget()
will give you the exact element that fired the event. You can then walk up until you find an element with some discriminant (e.g. a specific CSS class name), or walk down from the parent
element and use Element#isOrHasChild()
.
Have a look at how CompositeCell
dispatches the event to the appropriate cell,or how ButtonCell
checks that you clicked the button inside the cell.