You need to sign in to do that
Don't have an account?
Lightning Component Framework Specialist - step 4 aura:iteration not working
Hi, my code has passed the step 4 check, but when I try the search by boat type no boats appear on the BoatSearchResults component. I have done some debugging and found that it is not entering into the aura:iteration and can't figure out why. Hopefully someone can help me.
The string "going to AuraIteration" appears on the screen, but nothing else. The variable v.boats contains the right amount of items (I am testing it with Sailboat type and it has 2 items. It also has the right values in each object.
Here is my code:
BoatSearchResults.cmp
<aura:component controller="BoatSearchResults">
<aura:attribute name="boatTypeId" type="String" />
<aura:method name="search" description="gets the boatTypeId from BoatSearch component and runs the search"
action="{!c.doSearch}">
<aura:attribute name="boatTypeId" type="String" />
</aura:method >
<aura:attribute name="boats" type="Boat__c[]" />
<lightning:layout multipleRows="true" verticalAlign="center" horizontalAlign="center">
<aura:if isTrue="{!v.boats.length > 0}">
going to AuraIteration
<aura:iteration items="{!v.boats}" var="boatItem">
<lightning:layoutItem flexibility="grow" class="slds-m-right_small">
<h3>calling BoatTile</h3>
<c:BoatTile boat="{!boatItem}"/>
</lightning:layoutItem>
</aura:iteration>
<aura:set attribute="else">
<lightning:layoutItem class="slds-align_absolute-center" flexibility="auto">
<h3>No boats found</h3>
</lightning:layoutItem>
</aura:set>
</aura:if>
</lightning:layout>
</aura:component>
Also, can someone tell me how to post code so it looks like code (lined and with the option to copy, etc)
Thanks!
The string "going to AuraIteration" appears on the screen, but nothing else. The variable v.boats contains the right amount of items (I am testing it with Sailboat type and it has 2 items. It also has the right values in each object.
Here is my code:
BoatSearchResults.cmp
<aura:component controller="BoatSearchResults">
<aura:attribute name="boatTypeId" type="String" />
<aura:method name="search" description="gets the boatTypeId from BoatSearch component and runs the search"
action="{!c.doSearch}">
<aura:attribute name="boatTypeId" type="String" />
</aura:method >
<aura:attribute name="boats" type="Boat__c[]" />
<lightning:layout multipleRows="true" verticalAlign="center" horizontalAlign="center">
<aura:if isTrue="{!v.boats.length > 0}">
going to AuraIteration
<aura:iteration items="{!v.boats}" var="boatItem">
<lightning:layoutItem flexibility="grow" class="slds-m-right_small">
<h3>calling BoatTile</h3>
<c:BoatTile boat="{!boatItem}"/>
</lightning:layoutItem>
</aura:iteration>
<aura:set attribute="else">
<lightning:layoutItem class="slds-align_absolute-center" flexibility="auto">
<h3>No boats found</h3>
</lightning:layoutItem>
</aura:set>
</aura:if>
</lightning:layout>
</aura:component>
Also, can someone tell me how to post code so it looks like code (lined and with the option to copy, etc)
Thanks!
https://salesforce.stackexchange.com/questions/202767/cant-see-the-boats-appearing-step-4
https://developer.salesforce.com/forums/?id=9060G000000MUgLQAW
Please let me know if problem solves.
Dear ajay Duggi(Heptarc),
I tried your code, and am still getting the same thing. It is not going into the Aura:iteration :(
I followed the links you supplied and neither of them helped me.