3

I have a lightning component that dynamically renders an indeterminate number of child components.

Each child component represents an item in a list. I iterate through the list and create different types of child components depending on the properties of the item in the list. Each child has an input, which I expected to have been bound to the list item that was passed into the child component, and back up to the list.

So, if I check a box on the child component, I would expect that the boolean value on that value in the list on the parent component to be updated as well.

What I'm seeing though, is that when I interrogate the parent level component, the data in the original attribute (the composite object) does not update as the child components have their values modified.

When I have created child components using aura:iteration, the values are bound and update accordingly. Is the behavior in the markup distinctly unique from the behavior using $A.createComponent?

4

If you use $A.createComponent, you need to use component.getReference, otherwise you'll just be getting a copy of the value. For a specific item in the list, it should be something like component.getReference("v.itemlist["+index+"].checkbox"). You'll need to play with it a bit to get the references just right, but this information should get you started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.