I need to rerender a component when an attribute value is changed. I tried to put the init handler code into a helper function and called it in valueChange event handler but it did not work. Please give me some suggestions.

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

<!--js controller-->
doInit: function(component, event, helper){
    //This code is working correctly
dfButtonIdChange:function(component, event, helper){
   //I need to rerender the component here
  • Similar question salesforce.stackexchange.com/questions/122297/…
    – S..
    Jan 9 '17 at 12:16
  • Did you get an error? Would you be willing to share some code that demonstrates it not working?
    – sfdcfox
    Jan 9 '17 at 12:20
  • @sfdcfox the code is working correctly but I am not able to rerender the component when the value is changed. I tried refreshView but it refreshes everything which is currently in the view. Jan 9 '17 at 12:33
  • What is dfButtonId?
    – sfdcfox
    Jan 9 '17 at 12:36
  • What are you trying to rerender? Some more information about what happens in the dfButtonIdChange function would be helpful. Jan 9 '17 at 12:57

The framework will detect any attribute changes automatically and rerender dirty values so you shouldn't need to manually track and rerender.

  • This was true for me up until now. I am changing attributes present directly in markup in <aura:if > but nothing is rerendering. I don't know why. Any idea?
    – JaKu
    Feb 1 '17 at 14:49
  • Do you have a more complete example? Feb 1 '17 at 19:25
  • 1
    We have a case where this is happening. We are creating two arrays with references of objects. We are then dynamically creating components to display each item in those arrays. If we update a value in the original object and print out the value from component.get('v.myarray'), the value is updated in the array. However, the DOM doesn't get updated with the new value. Because of this we are trying to figure out a way to force a refresh.
    – dsharrison
    Jan 23 '18 at 20:43
  • @dsharrison I have the same issue - did you ever find out a solution?
    – berry120
    Jun 19 '18 at 14:16
  • @dharrison - i've got the same issue as well my components are next in 2 aura if's dont know if that has something to do with it Mar 20 '19 at 21:53

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.