You could also consider having the checkboxes in a second component that subscribes to an application event that you fire when you push the master button.
<aura:application >
<ui:button label="CheckAllBoxes" press="{!c.fireCheckAllCheckboxes}" />
<!-- iteration -->
<analysis:ComponentWithCheckbox />
<!-- /iteration -->
</aura:application>
controller
({
fireCheckAllCheckboxes : function(component, event, helper) {
var appevent = $A.get("e.analysis:CheckAllCheckboxes");
appevent.fire();
}
})
CheckAllCheckboxes event
<aura:event type="APPLICATION" description="CheckAllCheckboxes" />
ComponentWithCheckbox
<aura:component >
<aura:handler event="analysis:CheckAllCheckboxes" action="{!c.checkTheBox}" />
<ui:inputCheckbox aura:id="TheCheckBox" label="Checkbox" />
</aura:component>
ComponentWithCheckboxController
({
checkTheBox : function(component, event, helper) {
var TheCheckBox = component.find("TheCheckBox");
TheCheckBox.set("v.value",true);
}
})
Also, if the checkboxes all have the same aura:id, calling find() on the component will return an array with all of those components. If that works for you, you could do something like this:
<aura:application >
<aura:attribute name="numbers" type="Integer[]" default="[0,1,2,3,4,5,6,7]" />
<ui:button label="CheckAllBoxes" press="{!c.checkAllCheckboxes}" />
<aura:iteration items="{!v.numbers}" var="number">
<ui:inputCheckbox label="{!number}" aura:id="DependentCheckbox" />
</aura:iteration>
</aura:application>
Controller
({
checkAllCheckboxes : function(component, event, helper) {
var checkboxes = component.find("DependentCheckbox");
for (var i = 0; i < checkboxes.length; i++){
checkboxes[i].set("v.value",true);
}
}
})
Make sure your wrapper class is public and has the @AuraEnabled notation in its variables, as well as they are public with get;set; example:
public class wrapperClass{
@AuraEnabled public List<contact> lstContact{get;set;}
@AuraEnabled public Integer contactCount{get;set;}
@AuraEnabled public String headerMsg {get;set;}
}
Best Answer
You should be using
event.getSource().set("v.disabled", true);