Closed
Description
Your question and description of the problem goes here
How can give my variable the value of an item I clicked on? I can't use classwide varibales with this.
inside of the action function. I want to display an item's properties, e.g. label, color, time, inside of another html element. In my case I want to set the variable selectedTimeslot
to the item that has been clicked on.
Code
You can paste your code and data examples here if it will help to answer the question.
// the timeslot the user clicked one; the interface TimeSlot looks like this:
// https://gantt-schedule-timeline-calendar.neuronet.io/documentation/configuration/chart/items
public selectedTimeslot: TimeSlot = {} as TimeSlot;
public clickAction(element: any, data: any) {
function onClick(event: any) {
console.log(data.item);
console.log(GSTC.api.sourceID(data.item.id));
}
element.addEventListener('click', onClick);
return {
update(element: any, newData: any) {
data = newData;
},
destroy(element: any, data: any) {
element.removeEventListener("click", onClick);
},
};
}
// somewhere in the config
const config = {
/* ... */
actions: {
'chart-timeline-items-row-item': [this.clickAction],
},
/* ... */
};
Now I want public selectedTimeslot
to be data.item
- how can I achieve that?
Thanks a lot in advance!