[Solved] Click handling is super weird, false clicks?

What’s going on here? This has plagued me for a while and is super annoying.

Notice this one is NULL – because I clicked on a

tag

within the button, which doesnt have data to pass.

WHY is this being called? Because the parent has an action? :sa:

	'click .uiActionPropertyModal'(event){
		const target = event.target;
		alert(target.getAttribute('data-propertyId'));
		Modal.show('reportPropertyModal', function () {
			window.thePropertyId = target.getAttribute('data-propertyId');
			//return Cases.findOne(target.getAttribute('data-id'));
		});
	}
{{#each
 propertiesArray}}
									<div class="panel-body" >
										
										<div class="col-md-3">
											<a href="/project/{{_id}}" class="btn btn-info btn-block uiActionPropertyModal" data-propertyId="{{_id}}" style="{{getPropertyStatusCss}}">
												<h1>{{address1}}</h1>
												<h2>{{address2}}</h2>
												<h2>{{city}}</h2>
												<h2>{{province}}</h2>
												<h2>{{postal}}</h2>
											</a>
										</div>
										
										<div class="col-md-3">
											
											<p>Status: {{status}}</p>
											<p>Created: <time class="text-muted timeago" datetime="{{timeAgoCreated}}">{{timeAgoCreated}}</time></p>
											<p>Updated: <time class="text-muted timeago" datetime="{{timeAgoUpdated}}">{{timeAgoUpdated}}</time></p>
											<p>Risk Rating: {{riskRating}}</p>
											<p>Rating: {{riskRating}}</p>
											<p>Comments: {{overallComments}}</p>
											
										</div>
										
									</div>
								{{/each}}

Use event.currentTarget

event.target is the element that was clicked on, while currentTarget is the one that matches the click handler:

1 Like

Thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaank you.

1 Like

It’s nice when there’s a simple solution! :smiley:

2 Likes

Thanks! I can verify this was infact the solution. You rock dude, thanks. My software is so close to bug free.

These are the little quirks of Meteor that make it kinda hard to get in to. But obvious once you find it. Learning curves…

This one was a plain old browser DOM quirk! You’d get the same behaviour with any framework

But yeah there’s so many quirks with Meteor, Javascript and the DOM that it’s a lot to deal with haha

Understood and agreed.