Code not reliable - any way to 'foolproof'?

Hi!
I am using code to show/hide bio information in a repeater on this page:
https://www.borders-territories.space/team
Although working perfectly in preview mode, once the site goes live it works only every tenth attempt or so. Have tried on multiple computers, clearing cache etc, but the problem persists.
Grateful for some help.
Code below:

import wixData from 'wix-data';
$w.onReady(function () {
     $w("#biobutton").onClick(async (event, $w) => {
 const bio = await wixData.get('Team', event.context.itemId)
 
  $w('#textgroup').show();
  } );
} )
export function closebutton_click(event, $w)
 {
  $w("#textgroup").hide();
}

Hi,
I’m checking if it’s a problem on our end.
I’ll update once I have more info, hold on tight in the meantime :slight_smile:

Update: indeed an issue on our end, we’re investigating.

Thank you! There is also an issue with repeater item spacing (between first and second item for example) - don’t know if this is related?

Hi Helena,
We identified the problem and are working on a fix, although I cannot provide a deadline for that.
The bug only affects click handlers that were added using the “onClick” API.
If you add a click handler through the “biobutton” properties panel (same as you did for the close button) it will work. Meaning you need to do 2 things:

  1. Add a click event using the properties panel and put your wix data logic there
  2. Remove the current onClick code.
    Eventually your code should look something like this:
import wixData from 'wix-data';

$w.onReady(function () {
})

export function closebutton_click(event, $w) {
	$w("#textgroup").hide();
}

export function biobutton_click(event, $w) {
	const bio = await wixData.get('Team', event.context.itemId)
	$w('#textgroup').show();
}

Don’t copy paste the code above - use the properties panel to add the new click event.

Regarding the spacing, it shouldn’t be related, but it’s best to open a new forum post for that and paste a screenshot there.
Let me know if the above suggestion works. Thanks!

Tomer,
Works like a charm! I just removed the ‘await’ from your suggestion. Thank you.
Only thing is that now I get the ‘hand’ cursor over the entire page, not just when I hover over something clickable… Is this code related?

It’s because you have a “leftover” click handler on the entire page.
Select the page and remove the “page1_click” click handler in the properties panel:

Simple as that! Thank you so much Tomer.

You’re welcome, have fun coding!