Another Salesforce blog!!!

Salesforce, Apex

Dynamically Showing or Hiding Markup

Link

Use CSS to toggle markup visibility. You could use the tag to do the same thing but we recommend using CSS as it’s the more standard approach.
This example uses $A.util.toggleClass(cmp, ‘class’) to toggle visibility of markup.

<!--c:toggleCss-->
<aura:component>
    <ui:button label="Toggle" press="{!c.toggle}"/>
    <p aura:id="text">Now you see me</p>
</aura:component>
/*toggleCssController.js*/
({
    toggle : function(component, event, helper) {
        var toggleText = component.find("text");
        $A.util.toggleClass(toggleText, "toggle");
    }
})
/*toggleCss.css*/
.THIS.toggle {
    display: none;
}

Leave a Reply

Your email address will not be published. Required fields are marked *