0

The title says it. I have a function in the controller and I want to access it from renderer. But it doesn't seem to work. I tried to put the function in the helper but it didn't work either.

Controller:

checkDevelopers : function(component, event, helper){
    ...
}

Renderer:

afterRender : function(component, event, helper){
    this.superAfterRender();
    this.checkDevelopers(component, event, helper);
}
0

1 Answer 1

2

Controller methods are only available through the component.get("c.functionName") method. The typical use case would be to put methods you need to use all over the place in the helper script. Also, your afterRender syntax is incorrect, which is why that didn't work either. The parameters are component, helper, not component, event, helper. The following changes should work:

afterRender : function(component, helper){
    this.superAfterRender();
    helper.checkDevelopers(component, null, helper);
}
4
  • Thanks ! Do you know how can I call a helper function from the component itself ? I can't call "c.checkDevelopers" because the function is not in the controller anymore.
    – osos9
    Jan 9, 2019 at 15:03
  • @osos9 The helper object passed in to afterRender would allow you to call the method, as demonstrated in the answer.
    – sfdcfox
    Jan 9, 2019 at 15:04
  • I meant, from the component itself, I called the function and with "{!c.checkDevelopers}. But now it's in the helper, so is there an option to do like "{!h.checkDevelopers}" ?
    – osos9
    Jan 9, 2019 at 15:13
  • @osos9 Oh. No, the markup can only call controller methods.
    – sfdcfox
    Jan 9, 2019 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .