1

so the scenario is that i have an iteration within an iteration ....

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


    <aura:attribute name="PageQuestions" type="qf_Answers[]" />
    <aura:attribute name="PageQuestionsDropDowns" type="list" />

    <section class="slds-card">

        <lightning:card>


            <section class="slds-card slds-p-around_medium">
                <div class="slds-form"> 
                    <aura:iteration items="{!v.PageQuestions}" var="PQs" indexVar="PQsIndex">

                                        <!--PICKLIST-->
                                <aura:if isTrue="{!PQs.QuestionType == 'Picklist'}">
                                    <lightning:select aura:id="select" 
                                                      name="{!PQs.AnswerID}"
                                                      value="{!PQs.AnswerValue}"
                                                      messageWhenValueMissing="Please select a valid option"
                                                      required="{!PQs.QuestionRequired}">
                                        <option text="--Select an option--" value="" />
                                        <aura:iteration items="{!v.PageQuestionsDropDowns}" var="Dropdown" >
                                           <aura:renderIf isTrue="{!PQs.AnswerID == Dropdown.Listid}">
                                            <option text="{!Dropdown.DisplayValue}" value="{!Dropdown.ListValue}" />
                                            </aura:renderIf>
                                        </aura:iteration>


                                    </lightning:select>
                                </aura:if>


                    </aura:iteration>
                </div>
            </section>

        </lightning:card>


    </section>

</aura:component>

If i use the <aura:renderIf isTrue="{!PQs.AnswerID == Dropdown.Listid}">

it works without an issue, if i use the new

<aura:If isTrue="{!PQs.AnswerID == Dropdown.Listid}">

then i get an error, which is

Uncaught Action failed: aura:if$controller$handleTheTruth [Cannot read property 'N' of undefined] Callback failed: apex://qf_questionBuilder/ACTION$loadPageAnswers

looking at the line in the javascipt page/line that the error refers to it is saying it cant get an owner ( i am not using that property anywhere)

HtmlComponent.prototype.$setupComponentDef$ = function() {
this.$componentDef$ = $A.$componentService$.$getComponentDef$({"descriptor":"markup://aura:html"}); $A.$lockerService$.$trust$(this.$componentDef$, this); var owner = this.$getOwner$(); for(var ownerName = owner.$getType$();ownerName === "aura:iteration" || ownerName === "aura:if";) { owner = owner.$getOwner$(); ownerName = owner.$getType$() } $A.$lockerService$.$trust$(owner, this) };

Line error is on:

ownerName = owner.$getType$()

My concern is that now that renderif is depreciated this will stop working, i honestly cant see what is wrong, over to you guys for thoughts. All greatly received as ever.

1 Answer 1

5

Be careful with cAsE-sEnSiTiViTy:

<aura:If isTrue="{!PQs.AnswerID == Dropdown.Listid}">

Is not:

<aura:if isTrue="{!PQs.AnswerID == Dropdown.Listid}">

Aside from that, consider using eq instead:

<aura:if isTrue="{!PQs.AnswerID eq Dropdown.Listid}">

Note that the docs specifically state:

Don’t use the == operator for objects, as opposed to basic types, such as Integer or String. For example, object1==object2 evaluates inconsistently on the client versus the server and isn’t reliable.

Which may or may not affect your situation here.

3
  • thanks on both points, i will fix the code. useful feedback, i'll let you know if that fixes it Commented Feb 27, 2020 at 18:57
  • Thanks - didn't resolve the issue, but will use eq moving forwards ! Commented Feb 28, 2020 at 10:15
  • It's likely your action failing. Put a breakpoint there and I think you'll find an error. If that's not the problem, mock the expected data and get your page to render using that - if you are getting an error, then your expected data is not matching your actual. Commented Mar 1, 2020 at 7:00

You must log in to answer this question.

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