Good morning! I am currently blocking
After a long hour of searching, I got nowhere.
Let me explain:
I’m currently trying to make sure that, when you click on a line of a painting to link to a collection, it opens the dynamic page with the ID in question, each line in my collection to an ID.
So I tried this:
export function table1_rowSelect(event, $w) {
//Add your code for this event here:
wixLocation.to(“/Data/{C.I.D}”);
}
Instead of opening me as desired (for example: …/Data/56789), its opens a link like its:
Data/%7BC.I.D%7D
If anyone has a solution to my problem, I thank them in advance
Hi Corentin,
few things to know here:
- To use string interpolation (template literals, putting variables into strings), you need to use back ticks `` and prepend the expression with a dollar sign $.
So in your case, something like:
wixLocation.to(`/Data/${C.I.D}`);
- You need to use actual ID from collection item. If you have ID visible in your table something like this would work:
wixLocation.to(`/Data/${event.rowData._id}`)
If it is a Dynamic Page, chances are you used other field like title (you need to replace spaces with dashes):
wixLocation.to(`/Data/${event.rowData.title.replace(' ', '-')}`)
- If you don’t have the field visible in the table, you may need to use a different event for this. In this case, you can add onCurrentIndexChanged event handler to the dataset. There you could:
const currentItemId = $('#dataset1').getCurrentItem()._id // Or other attribute used in URL
wixLocation.to(`/Data/${currentItemId}`)
Let me know if you need any further assistance!
Thank you very much for your help, its working!