Hello again… To update you:
This concerns a collection search results table, here (search on Brussel, please):
http://www.mindfulmoment.be/practitioners-search
And a dynamic ITEM page, here:
http://www.mindfulmoment.be/practitioners-per-provincie/{practitionerID}
here’s a sample of a real entry:
http://www.mindfulmoment.be/practitioners-per-provincie/Savels
I am trying to detect an onClick in the FIRST COLUMN of the results table (event.target.id === “coll-ID”)
this is the column definition of the column I want to make clickable…
{
“id”: “coll-ID”,
“dataPath”: “practitionerId”,
“label”: “ID”,
“width”: 80,
“visible”: true ,
“type”: “string”,
“linkPath”: “link-field-or-property”
},
Still hitting a bit of a wall. Your link (in the reply you so graciously gave above) goes to the onSelect event handler, but I am pretty certain I need to use an onClick event handler. Is this correct?
**Assuming I need to use onClick: ** When I look at the code explanation, I am unable to find a complete example of using this code and I can’t figure out WHERE to put this function call. Overall, I think I understand what needs to be done…
-
Add OnClick event handler to detect a click on the table
-
Determine which column was clicked
-
If is the column I want: Determine the value in the cell that was clicked
-
Use the value in the path to call the dynamic ITEM page (wixLocation.to call)
I have come up with the following code to handle the click and redirect to the target dynamic item page, but when I add it to the page code, the search no longer works, and it does not show an error. The search is working fine without the added code.
import wixLocation from ‘wix-location’;
$w(“#table1”).onClick( (event, $w) => {
let targetId = event.target.id;
if (targetId === “coll-ID”) {
wixLocation.to(“/practitioners-per-provincie/” + event.cellData);
}
} );
QUESTIONS:
-
WHERE do I put the onClick event handler?
-
Does the onClick look for clicks anywhere in the table, or can I restrict it to a certain column?
-
If I cannot restrict it, then I am guessing I need to add an IF statement that says IF coll clicked === the coll I am interested in, then handle the onClick event… is this accurate?
-
Do I need an onSelect event handler too?
-
WHERE do I put the wixLocation.to code?
Ultimately, more complete examples of code would be REALLY helpful. I am an old-school software engineer and I can generally figure things out with good examples. Although your help section is fantastic in many ways… there seems to be a lot of details missing in the reference and the code examples.
I cannot thank you enough for any direction and hopefully examples.
Cynthia