It’s because .show() is not the opposite of collapse().
You have to decide either use hide-show or collapse-expand
The difference is that a hidden element occupies place whereas a collapsed element does not.
Hi J.D.,
I understand that part, but even when the "collapse()’ statement is getting executed it does not collapse the element. I verified using debugger that the code is getting executed with no result.
@jonatandor35 I am on a dynamic Item page where I want to collapse an image element if it’s not populated in db so that’s why onReady() I check for that field from DB and then collapse it. So when I am running this code in debugger to makes sure that my logic is correct…it does seem so, as I can see the right code getting executed depending on what’s in DB …but nothing happens. Not sure what else to do in this case …do you have any other suggestions ? or is there a way I can share the page with code with you ?
@singhsmanoj Perdón pero te lo digo en español. A mí tampoco me funcionaba pero después sí me funcionó porque de que me di cuenta que “extension” no es el nombre de un item en la página que está conectado a la base de datos, sino que “extension” es el nombre de un campo la base de datos, que suele ser un nombre que uno no ve mientras está editando en wix, sino sólo cuando va y mira la base de datos y ve las propiedades de ese campo.
Espero que te sirva mi explicación en castellano. Eso fue lo que me salvó a mí.
// Based on if your field is a text/URL type of input if ( item . fieldID1 === undefined ){
$w ( “#itemToHide” ). hide ();
$w ( “#itemToHide” ). collapse ();
} else {
$w ( “#itemToHide” ). show ();
$w ( “#itemToHide” ). expand ();
}
// Based on if your field is a boolean type of input if ( item . fieldID1 === true ){
$w ( “#itemToHide2” ). hide ();
$w ( “#itemToHide2” ). collapse ();
} else {
$w ( “#itemToHide2” ). show ();
$w ( “#itemToHide2” ). expand ();
}
});
});
NOTES:
If you’re using a field that has a typed input, you use “undefined”.
If you’re using a field that has a boolean check mark, you use “true”.