2

Using component.getReference("c.thisComponentFunction") to grab a reference for dynamically created components is a known feature. I'm not finding any documentation (or possibility) to do the same for a helper function for the same component.

Controller:

({
  doSomething : function(component, event, helper) {
    component.getReference("c.doSomethingElse"); //regular usage
    //component.getReference("helper.somethingElseInHelper"); //doesn't work
  },
  doSomethingElse : function(component, event, helper) {
    helper.somethingElseInHelper(component);
  },
})

Helper:

({
  somethingElseInHelper : function(component) {
    alert("you're in the helper!");
  },
})

Is there a way to directly access "helper.somethingElseInHelper" with component.getReference()?

  • Looks like the answer is "No, unless you're extending a component" which kind of defeats the purpose. It's easier to just add a dispatcher function on the component to its helper. – tsalb Nov 2 '17 at 17:19
3

You cannot directly access a helper of another component unless you are extending it. You will need to create a controller method to give access to a helper method.

  • Edited for clarity and what I want to achieve. I'm in the same component, can you clarify what you mean by extending it? – tsalb Nov 1 '17 at 6:20
  • 1
    Check this one out for extending components , developer.salesforce.com/blogs/developer-relations/2015/03/… – StormBr34ker Nov 1 '17 at 9:29
  • That's a great feature. I'm not seeing it apply directly to my use case unless I basically have a component with only helpers - and extend THAT for my component.getReference("c.someHelperFunction"). I guess that's the workaround. – tsalb Nov 1 '17 at 18:05

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.