[SalesForce] Uncheck child component checkboxes from parent button

How can I reach this behavior? My component is structured like this:

<aura:component>
     <button onclick="{!c.clearCheckbox}" />
     <aura:iteration items="{v.items} var="i">
           <c:checkboxItem />
     </aura:iteration>
</aura:component>

So, when I press the button on the parent, it have to clear all checkboxes created based on interation. I tried with an application event, but if I multiple times instance the parent component (for example 3 instances of the parent component (with all related childs), when I click on a button of a random instance component (for example the 2 instance) it fires the event and all children of all instances handle the event and I want to avoid this. Is there a better way for doing that, rather than a application event?

Best Answer

I solved this way:

I create a public method for my child component

<aura:method name="clearCheckboxes" action="{!c.clearCheckboxes}" />

clearCheckboxes : function(cmp,evt,hlp){
     // handle checkboxes clear
}

Then I call this method from the parent clear button click this way:

handleClearButtonClick : function(cmp,evt,helper){
     var children = component.find("child"); // I assign an aura:id="child" for every child component I istanciated
     for(var i=0; i < children.length; i++){
           children[i].clearCheckboxes();
     }
}