Search.../

context

Gets the context in which an event was fired.

Description

An event's context contains information about the circumstances surrounding the firing of the event. The context property only appears in events on repeated elements.

You can use the event context with $w.at() to get a selector function which selects items from a specific repeater item. It contains an object with one key:value pair. The key is "itemId" and the value is the ID of the repeated item on which the event occurred.

Type:

EventContextRead Only
NAME
TYPE
DESCRIPTION
type
string

"GLOBAL_SCOPE" for events fired outside of repeaters, or "COMPONENT_SCOPE" for events fired from repeaters.

itemId
string

ID of the repeater item where the event was fired from.

Was this helpful?

Get the context of the event

Copy Code
1// non-repeater event
2
3$w("#myElement").onEvent( (event) => {
4 let type = event.context.type; // "GLOBAL_SCOPE"
5} );
6
7
8// repeater event
9
10$w("#myRepeatedElement").onEvent( (event) => {
11 let $item = $w.at(event.context)
12 $item("#anotherRepeatedElement").value = "new value";
13
14 let itemId = event.context.itemId; // "item1"
15} );