You need to sign in to do that
Don't have an account?
Shiva 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.
Cmp:
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
Any help is greatly welcomed.
Thanks and Regards,
Shiva RV
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.
Cmp:
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 }" /> </div> </lightning:layoutItem> </aura:iteration> </lightning:layout> <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
buttonClear:function(component,event,helper) { var button = component.find({ instancesOf : "ui:button" }); button.set("v.label", "test"); alert(button); 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
May I suggest you please check with below link from the stack exchange community which will point you in the right direction.
- https://salesforce.stackexchange.com/questions/151696/how-to-get-all-buttons-in-my-page-from-a-controller-javascript-functioncomponen
Hope this helps.Thanks,
Nagendra