You need to sign in to do that
Don't have an account?
Sylvain DEVOS
slds-hide and javascript
Hello.
I am a beginner in development Salesforce, and I have a problem.
I try to show a section (div id:account) in a component but unsuccessfully.
Can you tell me where is my error.
Component
Controller
I am a beginner in development Salesforce, and I have a problem.
I try to show a section (div id:account) in a component but unsuccessfully.
Can you tell me where is my error.
Component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > ... <button class="slds-button slds-button_outline-brand" onclick="{!c.DisplayAccount}">Add Account</button> ... <div aura:id="Account" class="{!if(v.displayedSection == 'Account','slds-show','slds-hide')}"> <article class="slds-card"> <div class="slds-card__header slds-grid"> <header class="slds-media slds-media_center slds-has-flexi-truncate"> <div class="slds-media__figure"> <span class="slds-icon_container slds-icon-standard-account" title="account"> <lightning:icon iconName="standard:account" size="xx-small" alternativeText="-"/> <span class="slds-assistive-text">account</span> </span> </div> </header> </div> </article> </div> </aura:component>
Controller
DisplayAccount : function(component, event, helper) { component.set("v.displayedSection","Account"); }
Dynamically Showing or Hiding Markup
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_show_hide_markup.htm
Modifying DOM Elements Managed by the Lightning Component Framework
You can modify CSS classes for a component outside a renderer by using the $A.util.addClass(), $A.util.removeClass(), and $A.util.toggleClass() methods.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_dom_modify_framework.htm
IMPORTANT: .THIS.toggle could be .THIS .toggle for you (with a space between .THIS and .toggle (class))
This little difference is very important (otherwise that will never work for you).
All Answers
Dynamically Showing or Hiding Markup
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_show_hide_markup.htm
Modifying DOM Elements Managed by the Lightning Component Framework
You can modify CSS classes for a component outside a renderer by using the $A.util.addClass(), $A.util.removeClass(), and $A.util.toggleClass() methods.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_dom_modify_framework.htm
IMPORTANT: .THIS.toggle could be .THIS .toggle for you (with a space between .THIS and .toggle (class))
This little difference is very important (otherwise that will never work for you).
Thanks for the help.