I have added a click event handler on a particular template like this:
let tableFilter = this.template.querySelector('.' + strDataTableTargetId + '_filter');
tableFilter.addEventListener('click', this.handleCustomFilterEvents);
handleCustomFilterEvents(objEvent){
if (objEvent !== undefined && objEvent !== null && objEvent.target !== undefined && objEvent.target !== null &&
objEvent.target.classList !== undefined && objEvent.target.classList !== null){
if(objEvent.target.classList.contains('addFilterAnchor')){
this.addFilterRow(this.strTableClass); //Not able to access addFilterRow method
}
}
}
But still I am not able to access addFilterRow
method.
I tried accessing like this :
tableFilter.addEventListener('click', () => this.handleCustomFilterEvents);
But then the handler isn't even getting invoked.
Any thing I am missing?
Update (Answer)
I forgot to pass event, that is why it was not working with =>
This works:
tableFilter.addEventListener('click', (event) => this.handleCustomFilterEvents(event));
this.addFilterRow(this.strTableClass);
can you check ifobjEvent.target.classList
exist and then containsaddFilterAnchor
?tableFilter.addEventListener('click', (event) => this.handleCustomFilterEvents(event));