0

I have a Lightning component (parent), and it has another Lightning component embedded within it:

<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">

  <!-- markup above -->
    <c:CaptchaComponent aura:id="captcha" />
  <!-- markup below-->

</aura:component>   

The CaptchaComponent has a button (aura:id="myButton"). I want to be able to enabled/disable that button from the parent Lightning component's controller. I was hoping to be able to do something like this:

var captchaCmp = component.find("captcha");
captchaCmp.myButton.set("v.diabled", false);

What's the correct way of calling that from the parent component?

  • One of the better way would be to declare an aura:method in child component, and call it from parent component. – Raul May 14 at 14:05
  • @Matt Smith, Aura components also support 2 way binding, so, you can add a isDisabled attribute to your Captcha component – glls May 14 at 14:26
0

You can use an aura:method to achieve this. In the aura method defined in your child component's JavaScript (controller/helper), you can set an attribute which will in turn enable/ disable the button. Please refer the below link to learn more about aura:method.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_tag_method.htm

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.