Hello, Im Antoine and I try to create a cool site for my service society.
I'm french, 30 yo, no develloper.
On one page I have 3 repeaters.
The container of each repeater consists of an image and a title.
Repeater 1 is visible and the other 2 are hidden.
I wish that:
- when the visitor clicks on the container 1 of the repeater 1, the repeater 2 is displayed and the 1 is hidden.
- when the visitor clicks on the container 2 of the repeater 1, the repeater 3 is displayed and the 1 is hidden.
This code is not good because he affect all containers.
export function container1_click(event) { $w('#group1').hide() $w('#group2').show() }
Thank's for your help.
¿No hubiera sido más fácil con un cuadro multiestados?
Bonjour, voici la solution à mon problème, résolu grâce à David.
import {session} from 'wix-storage'; import wixData from 'wix-data'; $w.onReady(function () { var secteur = $w('#page1').title session.setItem("filtresecteur", secteur); console.log (session.getItem("filtresecteur")) }); $w.onReady(function () { $w('#dataset1').onReady(() => { $w('#repeater1').onItemReady(($item, itemData, index) => { let thisCategorie = itemData.title; $item('#image1').onClick(() => { $w('#dataset1').setFilter(wixData.filter().eq('categorie', thisCategorie)); }); }); }); }); export function vectorImage1_click(event) { $w('#dataset1').setFilter(wixData.filter().eq('firstView', true)); }
Voici mon email.
It should make things faster and easier haha.
It doesn't work.
Yes the collection field has more than one category per item.
In the code we filter the dataset1 data but it is not mentioned repeater2, normal?
Now in my editor, there is only one category that appears in the repeater2
We agree that I do not have to replace '#title' in the code by the title of each category ?
import wixData from 'wix-data'; $w.onReady(function () { $w('#dataset1').onReady(() => { $w('#repeater1').onItemReady(($item, itemData, index) => { let thisCategorie = $item('#title').text; $item('#title').onClick(() => { $w('#dataset1').setFilter(wixData.filter().contains('categorie', thisCategorie)); $w('#dataset1').refresh(); }); }); }); });
I searched all day, very complicated to find the info, I regret not having studied computer science at school.
Please, can you give me at least the beginning of the code?
So now I have
On one page 2 repeaters.
The first is displayed on loading and the second hidden.
The first repeater is not connected to a database, it has 2 fields: a title, an image.
The second repeater is connected to a database that contains 3 fields: a title, an image, a category.
I am looking for the method to:
-a visitor clicks on image1 of repeater1, then data of the "delivery" category are displayed in repeater 2.
-a visitor clicks on image 2 of repeater 1, then the data corresponding to the "transport" category are displayed in repeater 2
I try this but it's not the good result :
export function container1_click(event) { $w("#repeater1").forItems( ["item1"], ($item, itemData, index) => {
$w('#group1').hide() $w('#group2').show() }); }
I guess you meant to say: "when the visitor clicks on the container 2 of the repeater 1, the repeater 3 is displayed and the 2 is hidden. "
Anyway I'm not sure if you meant that clicking the any container in repeater1 will display repeater 2, or just clicking the first item in repeater1 (index=0) will display repeater 2.
please clarify.