You need to sign in to do that
Don't have an account?
Cristina Camacho
Lightning Component Framework Specialist Step 6: fire the event to redirect the user to the boat’s default detail page
Hello all,
why is the definition of my event not working?
BoatDetailController.js
BoatDetail.cmp
why is the definition of my event not working?
BoatDetailController.js
({ doInit: function (component, event, helper) { var viewRecordEvent = $A.get('event.force:navigateToSObject'); console.log("viewRecordEvent " + viewRecordEvent); if(viewRecordEvent){ console.log("showButton"); component.set('v.showButton', true); } }, onFullDetails : function(component, event, helper) { var homeEvent = $A.get("event.force:navigateToSObject"); homeEvent.setParams({ "recordId": component.get("v.boat.Id") }); homeEvent.fire(); } })
BoatDetail.cmp
<aura:component > <aura:attribute name="boat" type="Boat__c"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="showButton" type="Boolean" default="false"/> <lightning:card iconName="utility:anchor"> <aura:set attribute="title">{!v.boat.Contact__r.Name}'s Boat</aura:set> <aura:set attribute="actions"> <aura:if isTrue='{!v.showButton}'> <lightning:button label="Full Details" onclick="{!c.onFullDetails}" /> </aura:if> </aura:set> <lightning:layout multipleRows="true" > <lightning:layoutItem size="6" padding="around-small"> <div class="slds-p-horizontal--small"> <div class="boatproperty"> <span class="label">Boat Name:</span> <span><ui:outputText value="{!v.boat.Name}"/></span> </div> <div class="boatproperty"> <span class="label">Type:</span> <span><ui:outputText value="{!v.boat.BoatType__r.Name}"/></span> </div> <div class="boatproperty"> <span class="label">Length:</span> <span><ui:outputText value="{!v.boat.Length__c}"/> ft</span> </div> <div class="boatproperty"> <span class="label">Est. Price:</span> <span><lightning:formattedNumber value="{!v.boat.Price__c}" currencyCode="USD" style="currency" currencyDisplayAs="symbol"/></span> </div> <div class="boatproperty"> <span class="label">Description:</span> <span><ui:outputRichText class="slds-text-longform" value="{!v.boat.Description__c}"/></span> </div> </div> </lightning:layoutItem> <lightning:layoutItem size="6" padding="around-small"> <div class="imageview" style="{!'background-image: url(\'' + v.boat.Picture__c + '\')'}" /> </lightning:layoutItem> </lightning:layout> </lightning:card> </aura:component>
Cristina Camacho
One more comment to clarify the issue here. The event is working, and the button takes me to the details page layout of the boat, howerver, the challenge is failing