Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| richclient:emberjs:components [2018/01/26 12:56] – [Gestion des événements] jcheron | richclient:emberjs:components [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 225: | Ligne 225: | ||
| </ | </ | ||
| - | ==== Gestion des événements ==== | + | ===== Gestion des événements |
| Ligne 247: | Ligne 247: | ||
| - | Pour autoriser la propagation de l' | + | Pour autoriser la propagation de l' |
| <sxh javascript; | <sxh javascript; | ||
| import Component from ' | import Component from ' | ||
| Ligne 259: | Ligne 259: | ||
| </ | </ | ||
| - | ==== Actions ==== | + | Voir la liste des [[https:// |
| + | |||
| + | ===== Actions ===== | ||
| + | |||
| + | Création d'un composant appelant l' | ||
| + | |||
| + | Générer le composant : | ||
| + | |||
| + | <sxh bash; | ||
| + | ember generate component action-button | ||
| + | </ | ||
| + | |||
| + | |||
| + | Implémenter le template du composant **action-button** : | ||
| + | |||
| + | <sxh html; | ||
| + | <button {{action " | ||
| + | </ | ||
| + | |||
| + | Le template invoque l' | ||
| + | |||
| + | <sxh javascript; | ||
| + | import Ember from ' | ||
| + | |||
| + | export default Ember.Component.extend({ | ||
| + | actions: { | ||
| + | doButtonThing() { | ||
| + | this.sendAction(' | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | </ | ||
| + | |||
| + | |||
| + | Le composant peut maintenant être utilisé dans une route /test : | ||
| + | |||
| + | <sxh html; | ||
| + | {{# | ||
| + | </ | ||
| + | |||
| + | |||
| + | l' | ||
| + | |||
| + | <sxh javascript; | ||
| + | import Route from ' | ||
| + | |||
| + | export default Route.extend({ | ||
| + | actions: { | ||
| + | continue() { | ||
| + | console.log(" | ||
| + | this.replaceWith(' | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | </ | ||
| + | |||