I have been implementing the MGT toolkit within my React + Typescript. It has all worked well, but I've tried to add a button within the template in the card. But the onClick doesn't seem to be working, I'm assuming this is something to do with the fact it is a template.
I see that there might be a problem as it is a template that might get copied across but I figured that the work around below would be fine. But whatever I get I can't get anything from the
const mgtPersonRef = useRef<null | MgtPerson>(null);
useEffect(() => {
const mgtPerson = mgtPersonRef.current;
if (mgtPerson === null) {
return;
}
mgtPerson.personCardInteraction = PersonCardInteraction.hover;
const button= mgtPerson.querySelector('#' + BUTTON);
if (button) {
button.addEventListener('onmousedown', () => {console.log("DONE IT!")});
return button.removeEventListener('onmousedown', () => void 0);
}
}, [mgtPersonRef.current]);
return <mgt-person
show-name={true}
user-id={id}
ref={mgtPersonRef}
>
<template data-type="person-card">
<mgt-person-card person-details="{{person}}" >
{
showButton
? <template data-type="additional-details">
<button
id={BUTTON}
>Click me</button>
</template>
: null
}
</mgt-person-card>
</template>
</mgt-person>;