I'm sure this is a simple issue but I can't for the life of me work it out. Long story short I'm trying to make clickable hashtags to filter repeaters filled from a database, I'm just stuck on a step along the way (but I'm sure I'll need help for the rest of the process so any ideas would be great). I have a text field on my page that was filled from a database. I want to get the value of that field (the actual hashtag) when it's clicked to use elsewhere (for now just console.log it) but I can only seem to get the placeholder text.
export function hashtags_click(event) {
console.log("Text: ", $w('#hashtags').text); //This is getting the placeholder text, not the value placed from the database
console.log("Value: ", $w('#hashtags').value); //Apparently this doesn't exist?
}
You can create a text field in your database and call it 'hashtags', for example. You can use JS split method to separate each individual hashtag to load them into a few text elements.
Then, in these text's onClick() function you can set a filter on your dataset that shows only database items in which the hashtag field contains the same hashtag value.
**There is an easier way to set this up where you can skip using .split() and instead just create multiple hashtag fields in your database, which will allow you to connect them using the GUI in the editor.