[Solved] Displaying tags on a dynamic page

I’m trying to follow this post:

https://www.wix.com/corvid/forum/main/comment/5ea2838452db5e002d7704c3

The code from the post is below:


exportfunction repeater1_itemReady($item, itemData, index)
{
//get tags from db for an item
let tags = itemData.tags;

//prepeate hashmap with tags to be diplayed
for ( var i = 0; i < tags.length; i++) { options.push({ “label” : tags[i], “value” : tags[i]}); }

//Set tags UI component $item( “#selectionTags1” ).options = options;
}


But I would like to put it on a dynamic page instead. I’m a total novice at this, this is as far as I’ve gotten:


export function selectionTags1_itemReady(options)
{
//get tags from db for an item
let tags = $w( ‘#csdb’ ).getCurrentItem().caresheetTags;

//prepeate hashmap with tags to be diplayed
for ( var i = 0 ; i < tags.length; i++) { options.push({ “label” : tags[i], “value” : tags[i]}); }

$w( “#selectionTags1” ).options = options;
}


Don’t I need to call the function somewhere? Should the “export function” go some place other than the dynamic page’s code?

Thank you for taking a look.

Attempt number two… still not working though :sweat_smile:

In a public js file:


export function csTagBox(options)
{
//get tags from db for an item
let tags = options;

//prepeate hashmap with tags to be diplayed
for ( var i = 0 ; i < tags.length; i++) { options.push({ “label” : tags[i], “value” : tags[i]}); }

}


Then on the dynamic page’s code:


Well, this is embarassing, I was doing everything wrong.

Here’s how you do it:

$w.onReady( function () {
var options = []
let tags = $w( ‘#csdb’ ).getCurrentItem().caresheetTags;
for ( var i = 0 ; i < tags.length; i++) {
options.push({ “label” : tags[i], “value” : tags[i]});
}
$w( “#selectionTags1” ).options = options;
});

How would you keep the text bolded after applying the above code to the tags?