[DOC] doc: add some info on t-key directive

This commit is contained in:
Géry Debongnie
2019-04-30 10:39:37 +02:00
parent eb910193d7
commit efe82b6cd0
2 changed files with 25 additions and 5 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ The complete documentation can be found [here](doc/readme.md). The most importan
- [Quick Start](doc/quick_start.md)
- [Component](doc/component.md)
- [Store](doc/store.md)
- [QWeb](doc/qweb.md)
## License
+24 -4
View File
@@ -226,14 +226,34 @@ If an expression evaluates to a falsy value, it will not be set at all:
## JS/OWL Specific Extensions
### t-on directive
### `t-on` directive
### Component: t-widget, t-props
### Component: `t-widget`, `t-props`
### t-ref
### `t-ref` directive
### t-key
### `t-key` directive
Even though Owl tries to be as declarative as possible, some DOM state is still
locked inside the DOM: for example, the scrolling state, the current user selection,
the focused element or the state of an input. This is why we use a virtual dom
algorithm to keep the actual DOM node as much as possible. However, this is
sometimes not enough, and we need to help Owl decide if an element is actually
the same, or is different. The `t-key` directive is used to give an identity to an element.
There are three main use cases:
- *elements in a list*:
```xml
<span t-foreach="todos" t-as="todo" t-key="todo.id">
<t t-esc="todo.text"/>
</span>
```
- *`t-if`/`t-else`*
- *animations*: give a different identity to a component. Ex: thread id with
animations on add/remove message.
### Debugging (t-debug and t-log)