Fix CRUD example to allow changing input values.

Currently, the first name and last name inputs fields can't be edited without the changes immediately being overwritten back to the selected person's first name and last name. This change will make it so that the input fields only get overwritten with the selected person's first name and last name when the selected person is changed.
pull/2860/head
Elliot Waite 5 years ago committed by GitHub
parent 2f80667f20
commit 4c805018e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,10 +30,7 @@
$: selected = filteredPeople[i];
$: {
first = selected ? selected.first : '';
last = selected ? selected.last : '';
}
$: reset_inputs(selected);
function create() {
people = people.concat({ first, last });
@ -53,7 +50,8 @@
}
function reset_inputs(person) {
({ first, last } = person);
first = person ? person.first : '';
last = person ? person.last : '';
}
</script>

Loading…
Cancel
Save