Managing events with Aurelia
We were explaining how to override and catch determined events and methods in the component life cycle, but what if we want to write our own methods and execute them when the user clicks on some button or moves the mouse for one section? We will start to delegate events.
The event delegation concept is a useful concept where the event handler is attached to one single element instead of multiple elements on the DOM. What implies that? Memory efficiency. It drastically reduces the number of event subscriptions by leveraging the bubbling characteristic of most DOM events.
On the other hand, we have the trigger concept. Similar, but not equal. You should use trigger binding when you need to subscribe to events that do not bubble (blur, focus, load, and unload).
Some examples are as listed:
- You need to disable a button, input, or another element
- The element's content is made up of other elements (reusable component)
In code words, it can be explained like this:
<select...