Hiding a button with IF function not working.

Hi!

On my site ( www.autonomic .com .co /el-carro-para-ti) i’m trying to show a load more button, whenever the “search” button is clicked… however, if no results are found, and the error message is showed, i want it hidden… however, no luck!! I’m a rookie in coding, so i cant’t really seem to be able to find the problem!

Here’s the code i’m using:

$w.onReady( function () {
$w( “#loadmorebutton” ).hide();
$w( “#repeater1” ).onItemReady( ($item, itemData, index) => {
$item( “#loadbutton” ).onClick( (event) => {
$w( “#loadmorebutton” ).show();

if ( $item( “#repeater1” ).collapsed) {
$item( “#repeater1” ).expand();
}

if ($item( “#errorMessage” ).show) {
$item( “#errorMessage” ).hide();
$item( “#loadmorebutton” ).hide();
}
else {
$item( “#loadmorebutton” ).show();
}

})
})
});

Thanks in advance for helping out!

Best regards,
JP