Introduction
Events can be caused by user interactions, such as clicking the mouse or pressing a key, or generated programmatically, such as hiding or showing an element using the hide() and show() functions.
Because the functionality provided by Event
can be inherited and used when actions
occur to elements, it is considered a "mixin."
About Mixins
Mixins provide functionality that other elements and event handlers can inherit and use.
Mixins are not elements. You cannot add mixins to a page in the Editor like other $w
elements,
and mixins are not meant to be used directly in your code.
For example, you would not write code like this, because it is out of context:
javascript | Copy Code$w("#Event").onEvent( (event) => {let eventType = event.type;} );
Instead, you can code the following if myElement
has an event handler that
"mixes in" Event
.
javascript | Copy Code$w("#myElement").onEvent( (event) => {let eventType = event.type;} );
Was this helpful?