Navigating to dynamic pages

I’m early in the design of this website and have rudimentary pages in place until I have the concepts down and can flesh them out.

I’ve set up a search of my collection to populate a table. I want users to be able to click on a row and have it go to the page for that item. But as of now, when they click on a row, it goes to the repeater page rather than the page for that item.

For example, from dot-iv .com/threat-database, if I search on “Kaczynski” and then select that row from the table, I want it to go to dot-iv .com/case-database/unabomber. However, it goes to dot-iv. com/case-database.

The code I’m using is

$w( “#table1” ).onRowSelect((event) => {
let rowData = event.rowData;
wixLocation.to( “/case-database/” + “#eventUniqueName” );
});

I know from the debug that rowData is being properly populated and eventUniqueName = Unabomber.

What have I got wrong here?

Also, once I have this working – for other searches, the eventUniqueName will be more than one word, so the table result will have spaces. But the URL replaces the spaces with dashes – is there a way to deal with that issue for the location code?

a table row is an object and you have to get a string from one of your column value:

let rowData = event.rowData;
let eventUniqueName = rowData["fieldKey"];
//and continue from here

Thank you!! That soved the main issue. Any thoughts on the other problem - the event name have spaces in most instances, but the URL replaces those with dashes. I could add another unique identifier to the collection, but I don’t want to have to display it, and as I understand it, only fields displayed in the table are returned in a search.

I found a prevous post of yours and tried:

$w( “#table1” ).onRowSelect((event) => {
let rowData = event.rowData;
let eventName = rowData[ “eventUniqueName” ];
eventName.replace(/\s+/g, ‘-’ );
wixLocation.to( “/case-database/” + eventName);
}

but that’s not making any replacements

If I understand correctly, you’re having trouble because you’re getting value with spaces, and a URL is different.
You can use this function to exchange a value for a URL
encodeURI ()
Then attach the value that returns you to the referral address


let url = encodeURI(value)