Wix Code Event Handlers Not Firing

The events are for a gallery component

The mouseOut and mouseIn events fire properly. The dblClick and itemClicked do not.

The itemClicked event does work if registered in the onReady function, but it fires when the page loads and throws an error in the console “Cannot read property ‘itemIndex’ of undefined”. The event should not fire on the page load.

Here is the code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixWindow from ‘wix-window’;

$w.onReady( function () {
$w(“#gallery1”).onItemClicked( (event, $w) => {
//let itemDescription = event.item.description; // “Description”
let itemIndex = event.itemIndex; // 3

    console.log("Item Clicked: " + itemIndex) 

}); 

} );

export function gallery1_mouseIn(event, $w) {

//Add your code for this event here:
console.log(“mouseIn—mouseIn—mouseIn—mouseIn—mouseIn”);
}

export function gallery1_itemClicked(event, $w) {

//Add your code for this event here:
console.log(“itemClicked—itemClicked—itemClicked—itemClicked—itemClicked”);

}

export function gallery1_dblClick(event, $w) {

//Add your code for this event here:
console.log(“dbClick—dbClick—dbClick—dbClick—dbClick”);
}

export function gallery1_mouseOut(event, $w) {

//Add your code for this event here:
console.log(“mouseOut—mouseOut—mouseOut—mouseOut—mouseOut”);
}

Hi Gvernie,

Look’s like something acting wrong in the gallery you are using, try it using another gallery such as Grid(portrait).

Best,
Mustafa

Why don’t Wix just fix stuff ??? this is still not working in 2024. onItemClick() on a gallery does not fire. It used to work when in Velo you could assign a function to the onClickItem handler on the right hand side of the Editor… since the editor changed and showed you an amber alert to change to to a different form of handler (the one in the post)… you then lose the function name approach… no matter if it worked… these don’t fire. c’mon Wix sort your act out.