0
<aura:iteration items="{!v.getrecords.record}" var="obj">
            <br/> Items:- <br/> {!obj.Itemname}, {!obj.itemsize} // I get all values here
            <ui:inputSelect aura:id="abc" disabled="{!!v.save}">
                <ui:inputSelectOption text="Yes" label="Yes"  />
                <ui:inputSelectOption text="No" label="No" />
                <ui:inputSelectOption text="Approved" label="Approved" value="true"/>
            </ui:inputSelect> 
    </aura:iteration>  

For this input select I am facing two issues

  1. In controller,this line is invoked when user clicks on save button

    var marketingValue = component.find("abc").get("v.value"); alert(marketingValue);

Error: [component.find(...).get is not a function] If the same input select option I put outside the aura:iteration , I get the desired value with no errors.

2.I wanted to default the input option on pageload (that is received controller) so i used the value attribute

<aura:iteration items="{!v.getrecords.record}" var="obj">
<br/> Items:- <br/> {!obj.purpose}, {!obj.legalGround } // I get all values here
<ui:inputSelect aura:id="abc" disabled="{!!v.save}">
<ui:inputSelectOption text="Yes" label="Yes" value="{!obj.status == 'yes'}" />
<ui:inputSelectOption text="No" label="No" value="{!obj.status == 'no'}"/>
<ui:inputSelectOption text="Approved" label="Approved" value="Approved" value="{!obj.status == 'approved'}"/>
</ui:inputSelect> 
</aura:iteration>

On page load, I do get the defaulted value but after clicking edit even if i change the value to something different , it auto reverts back to the controller received value, after doing 2-3 times it changed but again sometimes it goes back to the inital value.

5
  • aura:id cannot be set within an aura:iteration, it is currently not supported
    – glls
    Commented Apr 3, 2018 at 15:18
  • And there is an IDEA out there in regards to this: aura:id dynamic between aura:iteration
    – glls
    Commented Apr 3, 2018 at 15:21
  • 2
    Your problem is what prompted my idea as well.
    – sfdcfox
    Commented Apr 3, 2018 at 15:24
  • so what is the workaround , I do tried with var marketingValue = document.getElementById('abc'); I am receiving as blank (null) so how do I get the updated value ?...and also for status which I am using to make it as default ; is it something known issue as well..... :(
    – Abhik Dey
    Commented Apr 3, 2018 at 15:39
  • @sfdcfox: I will upvote your idea
    – Abhik Dey
    Commented Apr 3, 2018 at 15:40

0

Browse other questions tagged .