As we know that sometimes we have show content in Lightning components based on different conditions. There are 2 different options to achieve this:
Considerations while using slds-show or slds-hide class
Image snapshot showing component behaviour using inspect element:
Hope this will help!!!
Looking forward for everyone's comments and suggestion.
FIRING EVENT FROM LIGHTNING COMPONENT AND PASSING IT TO VF PAGE
CHANGES TO LIGHTNING DATA SERVICE IN SUMMER'17
LIGHTNING DATA SERVICES
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE
FIRE LIGHTNING EVENTS FROM VF PAGE
DYNAMICALLY CREATING AND DESTROYING LIGHTNING COMPONENTS
RAISING AND HANDLING CUSTOM EVENTS IN sALESFORCE lIGHTNING
WHY TO USE DESIGN RESOURCE AND HOW TO ADD DYNAMIC OPTION TO DATASOURCE
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE
PASSING INNER WRAPPER CLASS TO LIGHTNING COMPONENT
LIGHTNING COMPONENT FOR RECORDTYPE SELECTION FOR ANY SOBJECT
CUSTOM COMPONENT TO SHOW/HIDE SPINNER IMAGE
- By using <Aura:if > tag.
For example :
<aura:if isTrue="{!v.displayedSection == 'section1'}">
<!-- code to display information on UI -->
</aura:if>
- By using slds-show or slds-hide class on div.
For example :
<div class="{!if(v.displayedSection == 'section1','slds-show','slds-hide')}">
<!-- code to display information on UI -->
</div>
Considerations while using <Aura:if> tag
- Only the code present inside Aura:if for which condition returns true will be rendered as HTML.
- If you try to refer HTML component in controller.js present inside Aura:if which is not visible on UI because condition specified doesn't match, then you will get undefined value.
I have created a Lightning component to show Aura:if behavior along with snapshot from inspect element and console log statements to justify above 2 statements.
Considerations while using slds-show or slds-hide class
- All code present inside the div will be rendered as HTML irrespective of div class. Only the div for which class is slds-hide will not be visible on UI.
- All HTML components can be referred in controller.js irrespective of class specified on div.
I have created a lightning component to display slds-show or slds-hide behavior along with snapshot from inspect element to justify above statements.
Image snapshot showing component behaviour using inspect element:
Hope this will help!!!
Looking forward for everyone's comments and suggestion.
More Blogs>>:
INHERITANCE IN LIGHTNING
FIRING EVENT FROM LIGHTNING COMPONENT AND PASSING IT TO VF PAGE
CHANGES TO LIGHTNING DATA SERVICE IN SUMMER'17
LIGHTNING DATA SERVICES
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE
FIRE LIGHTNING EVENTS FROM VF PAGE
DYNAMICALLY CREATING AND DESTROYING LIGHTNING COMPONENTS
RAISING AND HANDLING CUSTOM EVENTS IN sALESFORCE lIGHTNING
WHY TO USE DESIGN RESOURCE AND HOW TO ADD DYNAMIC OPTION TO DATASOURCE
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE
PASSING INNER WRAPPER CLASS TO LIGHTNING COMPONENT
LIGHTNING COMPONENT FOR RECORDTYPE SELECTION FOR ANY SOBJECT
CUSTOM COMPONENT TO SHOW/HIDE SPINNER IMAGE
Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
ReplyDeletePython Training in Chennai
Digital Marketing Course in Chennai
Python Training Institute in Chennai
Best Python Training in Chennai
Digital Marketing Training
Digital marketing training institute in chennai
Excellent blog, very useful.
ReplyDeleteWeb and Pro Infomedia is Best Digital Marketing Company in Lucknow
ReplyDeletehttps://www.guest-articles.com/education/christmas-55-special-discount-offer-mcd-level-1-exam-28-12-2020
ReplyDeleteA portion of the unscripted TV dramas cover an individual or a gathering of individuals working on their lives.amazon.commytv
ReplyDeleteseating regions, adequate capacity, enormous organization illustrations, overhead signage, item shows. While these are as yet conceivable in inline shows, as far as possible what amount should be possible. primevideo.com/mytv activation code
ReplyDeletegood article organic honey!
ReplyDeleteOriginal
ReplyDeleteNecklaces: Necklaces draw attention to the neckline, elongating the neck and creating a more graceful appearance.
ReplyDeletehttps://www.dishisjewels.com/mangalsutras