+ Start a Discussion
Martha Vance 5Martha Vance 5 

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 &gt; 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!

 
Raj VakatiRaj Vakati
Refer this link

https://salesforce.stackexchange.com/questions/202767/cant-see-the-boats-appearing-step-4

https://developer.salesforce.com/forums/?id=9060G000000MUgLQAW
ajay Duggi(Heptarc)ajay Duggi(Heptarc)
Dear Martha Vance5,
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" 
                access="global" controller="BoatSearchResults">
    <aura:handler name="init" action="{!c.doSearch}" value="{!this}"/>
    <aura:attribute name="boatTypeId" type="String" />
    <aura:attribute name="boats" type="Boat__c[]" />  
    <!--<aura:method name="search" description="Sample method with parameter">
        <aura:attribute name="boatTypeId" type="String"  />
    </aura:method>-->
    <!-- set up the aura:method for search -->
    <aura:method name="search" description="accepts boatTypeId
            and executes search that refreshes the boats attribute">
        <aura:attribute name="boatTypeId" type="Id"/>
    </aura:method>
    <!-- Display errors, if any -->
    <!--
    <aura:if isTrue="{!not(empty(v.errorString))}">
        <div class="recordError">
            <ui:message title="Error" severity="error" closable="true">
                {!v.errorString}
            </ui:message>
        </div>
    </aura:if>-->
    <aura:if isTrue="{!not(empty(v.boats))}">
        <lightning:layout multipleRows="true" horizontalAlign="center">
                <aura:iteration items="{!v.boats}" var="boatVar">
                    <lightning:layoutItem flexibility="grow"  class="slds-m-right_small" >   
                        <c:BoatTile boat="{!boatVar}"/>
                    </lightning:layoutItem>
                </aura:iteration>
        </lightning:layout>
         <aura:set attribute="else">
            <div class="slds-align_absolute-center">No boats found</div>
        </aura:set>
    </aura:if>
</aura:component>
Please try code it may helps,
Please let me know if problem solves.
Martha Vance 5Martha Vance 5

Dear ajay Duggi(Heptarc),

I tried your code, and am still getting the same thing. It is not going into the Aura:iteration :(
Martha Vance 5Martha Vance 5
Raj,
I followed the links you supplied and neither of them helped me.