problem $w() is not a function

if in database the record add 3 équipements, i want to show 3 icons …for example. I have just made a test page and that is works but not works in “entreprises francophones detail”………test page is : https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=6a6b62d7-9bb6-40a6-b91b-6cff4a9200f4&referralInfo=dashboard

Where is the test page? I don’t see it.

Sorry here the page https://editor.wix.com/html/editor/web/renderer/edit/fa9ca072-2b07-4274-8cf8-810116b786cc?metaSiteId=54ba3451-ea8f-467c-a640-67e0b290e628&editorSessionId=66df80de-4e0b-47c1-ab05-535cc277a735&referralInfo=dashboard

The Editor URL doesn’t open up at the correct page. Please tell me which page.

Sorry good page is “Entreprises Francophones (Nom)”

For your test page, this should work for you:

import wixData from 'wix-data';

$w.onReady(function () {
   $w("#dynamicDataset").onReady(async () => {
   let num = $w("#dynamicDataset").getCurrentItem().equipements.length;
 for (var i = 0; i < num; i++) {
 let rech = $w("#dynamicDataset").getCurrentItem().equipements[i]
 let result2 = await wixData.query("Equipements")
                .contains("title", rech)
                .find()
            $w(`#act${i}`).src = result2.items[0].icon;
            $w(`#act${i}`).show();
        }
    });
});

You should realize, that although the above code worked for me, it wasn’t very fast. I would suggest that you keep all of the images in an array or a JSON object in a file in the site’s Public folder (you can see that in the Site structure panel on the left side of the Editor). Then, instead of a doing a database query for each icon, you can do a simple code lookup which is much faster.

I hope this helps.

OK thank you very much…this is the test page so why it does not works in “Entreprises francophones detail” ? For line $w ( #act${i} ). show ()

What is the problem with that line? Are you getting an error? Or doesn’t the image show?

@yisrael-wix i have tgis error : $w is not a function

@fredericmassard I’m sorry, but there’s something in your code that is causing the problem. but I can’t find it. Your code is just too complex for me to rewrite it. Your code had a number of problems and you will need to redo your code to conform to the way that I wrote it for your test page.

Make sure you use the dataset’s onReady() event handler as I did in my code.
Also, you should use await for the database queries. Otherwise, you will need to change the loop to handle all of the returned Promises together - Promise.all().

Array? Json ? I don t know how to do this…

@yisrael-wix OK thanks a

@fredericmassard Don’t worry. It’s something you can learn someday. It’ll make the display of the icons faster.

@yisrael-wix a tutorial exist ?

@fredericmassard

Here’s an excellent Javascript tutorial: https://javascript.info

For information on arrays, see this section: https://javascript.info/array
For information on Objects, see this section: https://javascript.info/object
For information on JSON: https://javascript.info/json

You can find tons more with an Internet search.

Good luck