0

I have a parent component with the below markup

<!--c:CarSearch -->
  <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
    <aura:handler name="searchCar" event="c:CarSearchEvent" action="{!c.doSearch}" />

    <lightning:card title="Manage Cars" class="bottom_margin">
        <!-- To make CarSearchForm child of this component include it here -->
        <c:CarSearchResult aura:id='CarSearchResult' />
    </lightning:card>

</aura:component>

And the controller has the below doSearch function

({
    doSearch : function(component, event, helper) {
        var carTypeId = event.getParam('carType');
        alert('selected car: '+ carTypeId);

        var carSearchResultComp = component.find('carSearchResult');
        alert('car search component: ' + carSearchResultComp);
        var carSearchResultCompResult = carSearchResultComp.searchCars(carTypeId);
        console.log('Auramethod result: ' + carSearchResultCompResult);
    }
})

<!--c:CarSearchResult -->
    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="CarRentalController" access="global" >

        <aura:handler name="init" value="{!this}" action="{!c.doInit}" />  

        <aura:attribute type="Car__c[]" name="cars" access="public" />
        <aura:attribute type="String" name="carTypeId" access="public" default="" />
        <aura:attribute type="Boolean" name="carFound" access="private" default="false" />

        <!--onsearch is in this controller-->
        <aura:method access="public" description="Search cars" name="searchCars" action="{!c.doSearch}" >
            <aura:attribute name="carTypeIdParent" type="String" default="" />
        </aura:method>
</aura:component>

The value for carSearchResultComp is showing undefined. Am I missing something? Please need help with what went wrong.
0

1 Answer 1

1

JavaScript is pervasively case-sensitive.

aura:id='CarSearchResult' != component.find('carSearchResult');

Use consistent casing and this basic structure should work, assuming that there is exactly one component with this aura:id.

1
  • Ah! Silly me.Glad I posted this ques here. You the best! Thanks you.
    – Deepu SFDC
    Mar 25, 2020 at 20:44

You must log in to answer this question.

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