You need to sign in to do that
Don't have an account?
Max Paq
Get all the values from an aura:iteration
Hello everyone,
Is there a way to get all the values from an aura:iteration element? Both output and input value? I have the following code in my component and I would like to get all the values in the inputNumber field, the {!subset} value and match them together.
<aura:iteration items="{!v.spaceSubsets}" var="subset"> <p>{!subset} <ui:inputNumber aura:id="detailRating" label='Rating'/></p> </aura:iteration>
The end goal here would be to click on a button and have the component insert multiple records into the database.
Bonus point if you could help me figure out how to only create record when a value is entered for one of the iteration.
Thank you all.
Facing the same issue - I need a data structure to save inputs inside an aura iteration. The aura:id's are dynamic so I can distinguish any input, but I cannot use the indexVar property to directly reference a varibale in an array in order to bind it directly to the lightning:input
Ideally I could doHas anyone found a good solution for this use case?
Theoretically, you could, on your inputs, put value="{!pos.quantity}", for example, and your array is dinamically changed (even if your "position" object doesn't have this attribute originally). Then, on your JS controller, you can iterate through "positions" and get "quantity" for each member of the array (if "Position" is an sObject, you can even use it to bind back to the Apex controller).
That said, @Max, is there a reason you're not using attributes on your "subset" records? If you make that into a JS object, with two attributes (e.g.: "output" and "input"), you can iterate on your controller and match those attributes as you like (maybe make a list that you populate depending on this "matching", that you send back to your Apex controller), like so: And, on the JS controller: