is it possible to pass some arguments from the onInit method of a Lightning component to be performed when the renderer finishes?
In my case I'm loading data in the onInit and want to modify some radio buttons' html based on the loaded data. I can't use
cmp.find('foo').getElement()
Because my radio buttons are not yet rendered, I was thinking about puting my loading code in the afterRender, but this seems wrong to me.
I've read, that there is an Event called aura:doneRendering, but it is not recommended to use it, since it can be called multiple times during the components lifecycle.
I was thinking about something like an asynchronous call from [onInit] with an anonymous function to be performed, after
this.superAfterRender();
so I can load my data, and tell the afterRender what I want to do with it.
While writing this, I figured that I can simply store my loaded data in an aura:attribute and use it in the afterRender
So my question is, which of these methods should be used, or is there another one?
- Store data from [onInit] in an attribute and retrieve it in afterRender()
- Load the data in afterRender()
- Use the doneRendering event