Aurelia if.bind inside repeat.for no se actualiza
Tengo un caso extraño en una plantilla de elementos de Aurelia con if.bind dentro de una repetición. Por no mostrarse / ocultarse cuando se cambia su propiedad subyacente. Con el siguiente código, los campos de edición deben mostrarse y el botón de edición debe ocultarse tan pronto como se haga clic en el botón de edición. Posteriormente, los botones guardar y deshacer deben ocultar los campos de edición y mostrar los botones de edición nuevamente.
MyList.ts:
import { computedFrom } from "aurelia-binding";
export class MyList
{
items: any[] = [{
"firstName": "Joe",
"lastName" : "Blow",
"id": 1
},
{
"firstName": "Jane",
"lastName" : "Doe",
"id": 2
}
]
editingItem: any = null
isEditing: boolean;
edit(item){
this.editingItem = item;
this.isEditing = true;
}
editFirst(item){
this.editingItem = this.items[0];
this.isEditing = true;
}
undo(){
// undo logic here
this.editingItem = null;
this.isEditing = false;
}
save(){
// Save logic here
this.editingItem = null;
this.isEditing = false;
}
}
MyList.html:
<template>
<table>
<tbody>
<tr repeat.for="item of items">
<td if.bind="!isEditing">
<button click.delegate="edit(item)">Edit</button>
</td>
<td>${item.firstName}</td>
<td>${item.lastName}</td>
<td if.bind="isEditing && editingItem.id == item.id">
<button click.delegate="save()">Save</button>
<button click.delegate="undo()">Undo</button>
<input value.bind="editingItem.firstName" />
<input value.bind="editingItem.lastName" />
</td>
</tr>
</tbody>
</table>
</template>
Al hacer clic en el botón editar no hace nada. Curiosamente, si agrego
${isEditing}
En cualquier lugar de la plantilla fuera de la repetición. Para, el código funciona como se esperaba. Es como si el motor de renderizado no supiera volver a renderizar elementos dentro del ciclo de repetición.
¿Es esto un error? ¿O estoy haciendo algo tonto?