Hi
I have a table on my page and am trying to use rowSelect to allow users to click and navigate to a dynamic page with more info. I am using this code:
export function table1_rowSelect ( event ) {
let rowData = event . rowData ;
console . log ( rowData );
wixLocation . to ( “/plant-list/” + rowData . botanical_name );
}
I don’t understand why I can’t get this to work. The row is selected on the screen but the link never opens and the event never triggers in the console. What am I doing wrong?
Which results do you get in console?
How do look like your database, especialy the dynamic DB-Fields, which were automaticaly generated when you converted your normal page into a dynamic one.
Is the shown code complete?
Where is the import-part?
Did you connect the selection-event of your table in the properties-panel?
A better way would be to put all your code inside onReady-code-part.
A better way would be to put all your code inside onReady-code-part.
OK, I modified to be inside the onReady code part and I got it to work now. I also realise I was using the wrong format for the URL. The dynamic page URL field key is link-plant-list-title, not botanical_name. I had to change from rowData.link-plant-list-title to rowData[“link-plant-list-title”] to make it work. It now looks like this:
$w ( “#table1” ). onRowSelect ( ( event ) => {
let rowData = event . rowData ;
console . log ( rowData );
wixLocation . to ( rowData [ “link-plant-list-title” ]);
});
I have another question: Is there a way to make wixLocation.to open a link in a new window?
@russian-dima I updated my comment while you replied ![:grinning: :grinning:](/images/emoji/google_classic/grinning.png?v=12)