I have the following code:
label.getElement().addEventListener("click", e->{
System.out.print("\nHello there\n");
});
But my app will, at times, add a different click listener to the same label. In some other frameworks, like android (the vaadin button acts the same), adding a second listener would remove the old one. However, in this case it does not.
How would I go about removing the listener in this case. So I only have a single click listener.
The addEventListener
method returns a DomListenerRegistration
instance that you can use later on to remove that specific listener (using the remove()
method).
Vaadin doesn't offer any way of removing all listeners.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.