• sonal gupta 36
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Salesforce Architect

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
can anyone help me solving the Second step for Lightning Component Framework Specialist super badge.. I struck in that badge.
Hi,

I am getting the following error eventhough I defined selected attribute .

User-added image

please check my code

boatserachresults:
<aura:component controller="BoatSearchResults">
    
    <aura:handler name="init" action="{!c.doSearch}" value="{!this}"/>
    <aura:attribute name="boats" type="Boat__c[]" />
    <aura:attribute name="boatTypeId" type="id" />
    <aura:attribute name="selectedBoatId" type="id" />

    <aura:method name="search" description="accepts boatTypeId
            and executes search that refreshes the boats attribute" action="{!c.search}" >
        <aura:attribute name="boatTypeId" type="Id"/>
    </aura:method>
    
    <aura:handler name="BoatSelect"
                  event="c:BoatSelect"
                  action="{!c.onBoatSelect}"
                  phase="capture"/>
    
     <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}" 
                                selected="{!v.selectedBoatId==boatVar.Id ? true : false }"/>
                    </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>

Boattilecmp:
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
	<aura:attribute name="boat" type="Boat__c" />
    <aura:attribute name="selected" type="boolean" default="false"/>

    <aura:registerEvent name="BoatSelect" type="c:BoatSelect"/>
    
    <lightning:button name="{!v.boat.Id}" class="{!v.selected? 'tile selected' : 'tile'}"
                       onclick="{!c.onBoatClick}" >
        <div style="{! 'background-image:url(\'' + v.boat.Picture__c + '\'); '}" class="innertile">
          <div class="lower-third">
           <h1 class="slds-truncate">{!v.boat.Contact__r.Name}</h1>
          </div>
        </div>
    </lightning:button>
</aura:component>