0

Having trouble getting this to work. This is what I have:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" 
            access="global" 
            controller="RequirementsUX">

<aura:attribute name="LeadRecord" type="object"/>
<!-- aura attributes to store data/values -->
<aura:attribute name="ListCivilWork" type="List"/> 
<aura:attribute name="ListSiteServiceNeededfor" type="List"/> 

<aura:attribute name="CivilWork" type="String"/>
<aura:attribute name="SiteServiceNeededfor" type="String"/>

<div> Site Services / Civil Work </div>
<lightning:layout multipleRows="true">
    <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
       <aura:iteration items="{!v.ListCivilWork}" var="CiWrk">
            <lightning:button variant="{!if(CiWrk.isSelected == true,'brand','brand-outline')}" label="{!CiWrk.value}" name="{!CiWrk.value}" title="Neutral action" onclick="{!c.cwButton }" disabled="{!v.disablepicklistvalues}"/>
        </aura:iteration>
    </lightning:layoutItem>
</lightning:layout>  

<aura:if isTrue="{!v.ListCivilWork == 'true'}">
<div> Site Service Needed for? </div>
<lightning:layout multipleRows="true">
    <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
        <aura:iteration items="{!v.ListSiteServiceNeededfor}" var="SSNF">
            <lightning:button variant="{!if(SSNF.isSelected == true,'brand','brand-outline')}" label="{!SSNF.value}" name="{!SSNF.value}" title="Neutral action" onclick="{!c.ListSSNFButtons}" disabled="{!v.disablepicklistvalues}"/>
        </aura:iteration>
    </lightning:layoutItem>
</lightning:layout>          
</aura:if>

CivilWork is a check box, but its displayed in the component as buttons. Button names are true and false.

When true is clicked, Site Service Needed for section below should show and when false is clicked that section should hide.

1 Answer 1

0

ListCivilWork is an array - it will never evaluate to either 'true' or true.

Try this:

<aura:if isTrue="{! !empty(v.ListCivilWork)}">

This will evaluate to true if the list is NOT empty.

2
  • Nothing happens when clicked on the true or false buttons...the section stays visible always. It should not show when false button is active and should show when true button is active.
    – Col
    Commented Apr 12, 2022 at 10:40
  • That's for you to implement. ListCivilWork is an ARRAY. It's not a boolean. If you do want to use a boolean, then you'll need a new attribute - perhaps something like showCivilWork which you would set on the checkbox click. Commented Apr 12, 2022 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .