$w.GalleryItemClickedEvent

$w.GalleryItemClickedEvent

Event that is fired when an image in a gallery is clicked.

Mixes In

$w.GalleryItemChangedEvent, $w.Event

Contents

context Gets the context of the event on a repeated element.
item Gets the gallery item.
itemIndex Gets the gallery item's index.
target Gets the element that the event was fired on.
type Gets the type of event that was fired.
context

context

Gets the context of the event on a repeated element.

Syntax

get context(): Object

Description

The context property only appears in events on repeated elements.

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

Object

Examples

Get the context of the event

JHcoIiNteVJlcGVhdGVkRWxlbWVudCIpLm9uRXZlbnQoIChldmVudCwgJHcpID0+IHsKICBsZXQgaXRlbUlkID0gZXZlbnQuY29udGV4dC5pdGVtSWQ7ICAvLyAiaXRlbTEiCn0gKTsK
$w("#myRepeatedElement").onEvent( (event, $w) => {
  let itemId = event.context.itemId;  // "item1"
} );

Mixed In From

$w.Event

item

item

Gets the gallery item.

Syntax

get item(): GalleryItem

Type

GalleryItem

Examples

Get the event's image properties

JHcoIiNteUdhbGxlcnkiKS5vbkV2ZW50KCAoZXZlbnQsICR3KSA9PiB7CiAgbGV0IGltYWdlU3JjID0gZXZlbnQuaXRlbS5zcmM7ICAgICAgICAgICAvLyAiNWE0NzQ2NzllYWM4NDRlM2EyLmpwZyIKICBsZXQgaW1hZ2VEZXNjID0gZXZlbnQuaXRlbS5kZXNjcmlwdGlvbjsgIC8vICJJbWFnZSBkZXNjcmlwdGlvbiIKICBsZXQgaW1hZ2VUaXRsZSA9IGV2ZW50Lml0ZW0udGl0bGU7ICAgICAgIC8vICJBbHQgdGV4dCIKICBsZXQgaW1hZ2VMaW5rID0gZXZlbnQuaXRlbS5saW5rOyAgICAgICAgIC8vICJodHRwOi8vd3d3LndpeC5jb20iCiAgbGV0IGltYWdlVGFyZ2V0ID0gZXZlbnQuaXRlbS50YXJnZXQ7ICAgICAvLyAiX2JsYW5rIgp9ICk7Cg==
$w("#myGallery").onEvent( (event, $w) => {
  let imageSrc = event.item.src;           // "5a474679eac844e3a2.jpg"
  let imageDesc = event.item.description;  // "Image description"
  let imageTitle = event.item.title;       // "Alt text"
  let imageLink = event.item.link;         // "http://www.wix.com"
  let imageTarget = event.item.target;     // "_blank"
} );

Mixed In From

$w.GalleryItemChangedEvent

itemIndex

itemIndex

Gets the gallery item's index.

Syntax

get itemIndex(): Number

Type

Number

Examples

Get the event's image properties

JHcoIiNteUdhbGxlcnkiKS5vbkV2ZW50KCAoZXZlbnQsICR3KSA9PiB7CiAgbGV0IGltYWdlU3JjID0gZXZlbnQuaXRlbUluZGV4OyAvLyAzCn0gKTsK
$w("#myGallery").onEvent( (event, $w) => {
  let imageSrc = event.itemIndex; // 3
} );

Mixed In From

$w.GalleryItemChangedEvent

target

target

Gets the element that the event was fired on.

Syntax

get target(): string

Type

Element

Examples

Get the ID of the target element

JHcoIiNteUVsZW1lbnQiKS5vbkV2ZW50KCAoZXZlbnQsICR3KSA9PiB7CiAgbGV0IHRhcmdldElkID0gZXZlbnQudGFyZ2V0LmlkOyAgLy8gIm15RWxlbWVudCIKfSApOwo=
$w("#myElement").onEvent( (event, $w) => {
  let targetId = event.target.id;  // "myElement"
} );

Mixed In From

$w.Event

type

type

Gets the type of event that was fired.

Syntax

get type(): string

Type

String

Examples

Get the type of the event

JHcoIiNteUVsZW1lbnQiKS5vbkV2ZW50KCAoZXZlbnQsICR3KSA9PiB7CiAgbGV0IGV2ZW50VHlwZSA9IGV2ZW50LnR5cGU7IC8vICJjbGljayIKfSApOwo=
$w("#myElement").onEvent( (event, $w) => {
  let eventType = event.type; // "click"
} );

Mixed In From

$w.Event