Please refer link: Lightning Change Event

Suppose we are using handler as follows:

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

Now, It seems the handler would could the expenseNameChanged method in following two cases:

  1. When User updates the expenseName field from UI (by editing some field in form)
  2. If we update the field from code (may be from helper/controller component of lightning component)

Question: Is it possible that event get fired only when user updates the data from UI (option 1 above) and expenseNameChanged method don't get cal when we update the field from code.

  • 1
    Are you using aura component such as ui:inputText ? If yes, won't using change attribute : change="{!c.expenseNameChanged}" would work for you? – Praveen Nov 7 '16 at 9:31
  • Thanks Praveen. I am now using change attribute. Could you please refer any doc or link that explains when to use handlers and change attribute. – Ayush Shukla Nov 10 '16 at 8:15

I don't think it is possible.

A simple workaround would be to set a global variable from your helper function - before you update the field, then on the handler function - check if that variable was set, and only then execute your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.