Search.../

onItemClicked( )

Adds an event handler that runs when an item in a gallery is clicked.

Syntax

function onItemClicked(handler: GalleryItemClickedEventHandler): Gallery
handler: function GalleryItemClickedEventHandler(event: GalleryItemClickedEvent): void

onItemClicked Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when a gallery item is clicked.

Returns

The gallery that triggered the event.

Return Type:

GalleryItemClickedEventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that has occurred.

Returns

This function does not return anything.

Return Type:

void

Related Content:

Was this helpful?

Get the information of the item that was clicked

Copy Code
1$w("#myGallery").onItemClicked( (event) => {
2 let itemDescription = event.item.description; // "Description"
3 let itemIndex = event.itemIndex; // 3
4} );
Expand a gallery image that was clicked

Copy Code
1$w('#myGallery').onItemClicked( (event) => {
2 $w('#myGallery').clickAction = 'expand';
3} );