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

Was this helpful?

Get the context of the event

Code Example

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} );