Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thomas Shipley @tdshipley 11:13
- Woops deleted the message when all I wanted to do was fix a typo :(
- Sorry for the spam...
- I have a form which has a section which might contain some fields or not based on if a test has some input values. To manage this I have a array on a view model object which when the user wants to add a test input they click a button to add a new empty one to the array:
- addTestInput() {
- this.vm.test.testInputs.push({
- argumentName: "",
- valueType: "",
- value: ""
- });
- }
- Then in the UI I loop over each object in the array and create form elements to edit the objects properties.
- <template if.bind="vm.test.testInputs.length > 0" repeat.for="testInput of vm.test.testInputs">
- <div class="form-group">
- <label for="testInputArgumentName${$index}">Argument Name</label>
- <input value.bind="testInput.argumentName" type="text" class="form-control" id="testInputArgumentName" placeholder="Argument Name">
- </div>
- /* More fields ...*/
- This works when the user first presses the add test input button. A test input object is added to the array and the fields for it are shown in the UI. But when I press the button for the second time a second object is added to the array. But additional fields for the new object are not added to the UI. I have read http://blog.williamhayes.org/2015/08/dynamic-input-list-in-aurelia.html but I don't seem to be able to get it working. Anyone have any ideas - they would be greatly appreciated :)
- Jason Sobell @jsobell 11:13
- @tdshipley What happens if you add something like
- get testInputs() { return vm.test.testInputs; }
- and run it against that? The array tracking stuff tends to be troublesome, so I don't know if that might help or not, but try the whole thing with a simple array at the VM level instead of nested in an object
- Jason Sobell @jsobell 11:19
- Oh, and id="testInputArgumentName" should say id="testInputArgumentName${$index}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement