I have an issue. In preview, for one item, when I click on “reserveButton”, the item “group1” appears. This is what I want. But when I publish my website and click on “reserveButton” the “group1” doesn’t appear. Did I write something wrong? Thanks for your help.
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
$w.onReady( function () {
$w( ‘#title1’ ).show();
$w( ‘#description’ ).show();
$w( ‘#group1’ ).hide();
$w( ‘#thanks’ ).hide();
$w( ‘#repeater2’ ).onItemReady(($item, itemData) => {
if (itemData.isReserved === true ) {
$item( ‘#reserveButton’ ).hide();
$item( ‘#alreadyReserved’ ).show();
} else {
$item( ‘#reserveButton’ ).show();
$item( ‘#alreadyReserved’ ).hide();
$item( ‘#reserveButton’ ).onClick(event => {
$item( ‘#reserveButton’ ).hide();
$item( ‘#group1’ ).show();
});
}
});
});
I also tried by using this function, but “group1” of every items appears :(.
export function reserveButton_click(event) {
$w( ‘#repeater2’ ).onItemReady(($item) => {
$item( ‘#group1’ ).show();
$item( ‘#reserveButton’ ).hide();
}); }
Your SANDBOX-DB and LIVE-DB is synced? (Identical DATABASES?)
@imanusylvie
Also checked DB-Permissions?
@russian-dima Yes, it is in french, but it says that everybody can access to the collection
@imanusylvie Je comprend. Je sais quoi est —> “toute le monde”
Ok, then i also have no idea, sorry.
Since #group1 is not in the Repeater , but rather on the page itself, you should use $w for #group1, like this:
$item('#reserveButton').onClick(event => {
$item('#reserveButton').hide();
$w('#group1').show();
});
@russian-dima Seriously? French? German, Russian, English, and now French? Oh yeah - Javascript too.
@russian-dima haha c’est très bien !
Thanks for trying to help
@yisrael-wix group1 is in the repeater. Maybe I should add some videos to be more explicite.
This is what I have and want in preview: when I click on “Réserver” the group1 appears.
And this is what I have in published version, when I click on “Réserver”, nothing appears:
The page onReady() code shows #group1:
$w('#group1').hide();
If #group1 is in the Repeater, then this is incorrect.
Please post the URL of your site and explain how and where to see this issue.
BTW, your reserveButton_click() is incorrect. If you want to use a standalone event handler for the Repeater reserve buttons, you need to use the Repeated Item Scope . See the article Retrieve Repeater Item Data When Clicked to see how to write an event handler for an element in a Repeater.
@yisrael-wix You lit up my brain !
Problem solved by changing
" $w( ’ #group1 ’ ).hide();" to "$item( ’ #group1 ’ ).hide(); " and moving it in onItemReady function.
$w.onReady( function () {
$w( ’ #title1 ’ ).show();
$w( ’ #description ’ ).show();
$w( ’ #thanks ’ ).hide();
$w( ’ #repeater2 ’ ).onItemReady(($item, itemData) => {
$item( ’ #group1 ’ ).hide();
…
});
});
Thanks a lot !
@yisrael-wix Yeah, i try to be always multitasking/multilingual. I am lucky in this situation (lived for some time in France ).