+ Start a Discussion
Shiva RajendranShiva Rajendran 

How to get all the buttons present in a component in js controller in lightning?

Hello Everyone,
I have a component , which creates lightning:button dynamically in iteration. Could i get all the buttons created in the js controller by some logic?
I just want to disable one button out of the 25 dynamically created button.

aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" controller="LightningBingoBoardCreatedAuraClass">
<aura:attribute name="BoardClass" type="LightningArrayWraperClass[]">    </aura:attribute>

    <aura:attribute name="chosenValues" type="String[]">    </aura:attribute>

   <aura:iteration items="{!v.BoardClass}" var="item">
        <lightning:layout horizontalAlign="space">

                   <aura:iteration items="{!item.arrayClass}" var="inneritem">
       <lightning:layoutItem flexibility="auto" padding="around-small">
       <div aura:id="{!inneritem.value}">
           <lightning:button variant="neutral" label="{!inneritem.value}" onclick="{! c.buttonClickEventFire }" />
 <lightning:button variant="neutral" label="clear all" onclick="{!c.buttonClear}"/>

Basically there are 25 buttons with unique labels to it. I just want to disable the button based on the value entered in a text box which matches the button label. I just want to know how to get all the buttons present inside the component from js controller code
                var button = component.find({ instancesOf : "ui:button" });
    button.set("v.label", "test");
     var com=component.get("v.LightningArrayWraperClass.BoardClass");
/*   var button = component.find({ instancesOf : "ui:button" }); this code didnt work ,the button was always null

Any help is greatly welcomed.

Thanks and Regards,
Shiva RV
Best Answer chosen by Shiva Rajendran
NagendraNagendra (Salesforce Developers) 
Hi Shiva,

May I suggest you please check with below link from the stack exchange community which will point you in the right direction. Hope this helps.