[Solved] Getting click event data is "null" when clicking child element

Hi guys,

'click .ui_action_case_modal'(event, template){

I can fetch the appropriate data, when I click on the parent div, but I have child elements inside, which still fire the event, however, no data is present.

Here is the code:

	'click .ui_action_case_modal'(event, template){

		const target = event.target;

		console.log(target.getAttribute('data-id')); // THIS ONLY WORKS WHEN CLICKING THE ACTUAL DIV, NOT THE CHILDREN :( 

		Modal.show('caseModal', function () {
			window.caseModalId = target.getAttribute('data-id');
			return Cases.findOne(target.getAttribute('data-id'));


Try to use event.currentTarget.


THANK YOU. I had some code somewhere, couldn’t friggin remember it.

Search and replace… so many bugs fixed. LOVE YOU <3 I needed this at 5:30 am…

1 Like

Glad I helped you! Often simplest things are the best.

1 Like