Lightning: How to ignore valueChange event handler from parent component if sub component ‘overrides’ it?

There are parent and sub components. Each component has :

<aura:handler name="change" value="{!v.var}" action="{!c.onVarChange}"/>

Each component defines onVarChange in its controller respectively. But for sub-component we have the following execution flow:

  1. parent.onVarChange
  2. sub.onVarChange

So both parent and sub compoents’ handlers are called for sub component.

How to ignore execution of handler on parent component parent.onVarChange when we use sub component ?


You want the equivalent of stopPropagation() which doesn’t exist yet. Sorry. You could fake it by setting properties on the component and checking them at the different levels. Hacky but maybe your only option.

Source : Link , Question Author : Natallia , Answer Author : Kris Gray

Leave a Comment