function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phuc Nguyen 18Phuc Nguyen 18 

disable button after click and enable div

Hello,
I have a button that needs to be disabled.  Ideally after it has successfully created a record:
<button label="My Button" class="slds-button slds-button--brand" onclick="{!c.submit}">Submit Button</button>

Enable/show this div so that the child component is available
<div style="text-align:right;">
            <c:child parentId="{!v.id}"/>
        </div>

Thanks,
P
Best Answer chosen by Phuc Nguyen 18
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Phuc,
For Disabling a button you can create an boolean attribute in the component and use this attribute in the disabled attribute of button tag.Whenever you want to disable the button in the click you can make the attribute to true,so that the button will be disabled.
In component add these lines

  <aura:attribute name="isdisabled" type = "boolean" />
    <button label="My Button" class="slds-button slds-button--brand" disabled = "{!v.isdisabled}" onclick="{!c.submit}">Submit Button</button>

In submit method of controller add this line 

    component.set("v.isdisabled",true);

To enable  div refer this link which might help you in this
https://developer.salesforce.com/forums/?id=9060G0000005n0BQAQ

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Phuc,
For Disabling a button you can create an boolean attribute in the component and use this attribute in the disabled attribute of button tag.Whenever you want to disable the button in the click you can make the attribute to true,so that the button will be disabled.
In component add these lines

  <aura:attribute name="isdisabled" type = "boolean" />
    <button label="My Button" class="slds-button slds-button--brand" disabled = "{!v.isdisabled}" onclick="{!c.submit}">Submit Button</button>

In submit method of controller add this line 

    component.set("v.isdisabled",true);

To enable  div refer this link which might help you in this
https://developer.salesforce.com/forums/?id=9060G0000005n0BQAQ

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
This was selected as the best answer
Phuc Nguyen 18Phuc Nguyen 18
Thank you Devi!