Thanks to help here I have successfully made a button disappear on click.
However, I'm not yet successful controlling css using aura:handler init methods.
Repro: 1) Created this component 2) Loaded tab with the component
Expected: Alerts fire & ui:button is invisible due to display: none applied
Actual: Alerts fire but ui:button is visible and display remains inline-block
Component
<aura:component implements="force:appHostable" controller="updateUsingLightningCheckboxController">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<ui:button label="Activate" press="{!c.onActivate}" aura:id="Activate"/>
</aura:component>
JS Controller:
({
doInit: function(cmp) {
alert('fired');
//This does not work:
var cmpTarget = cmp.find("Activate");
$A.util.addClass(cmpTarget , 'invisible');
alert('fired after activate');
},
onActivate: function(cmp, evt, helper){}
//This works
var cmpTarget = cmp.find("Activate");
$A.util.addClass(cmpTarget , 'invisible');
})
CSS:
.THIS.invisible {
display: none;
}