diff --git a/src/itemcontroller.js b/src/itemcontroller.js index ba54553469f8dc4420943f2ed4fcfa7f069516a5..c05a36737bb2b822dd33e25bc3d40d33caadf3bf 100644 --- a/src/itemcontroller.js +++ b/src/itemcontroller.js @@ -44,7 +44,7 @@ export default class ItemController { changeModus(newModus) { this.modus = newModus; - if (this.modus === 'view') { + if (newModus === 'view') { // reload item to current state, patches do not return embeddinds... this.handler.getItem(this.id, this.embedded).then((item) => { this.data = item; diff --git a/src/views/itemView.js b/src/views/itemView.js index 60806ef0d7af1796e505bddc32d83050aef22dfc..13c45039ef82b8e56157ae659b29ece39adcac97 100644 --- a/src/views/itemView.js +++ b/src/views/itemView.js @@ -21,8 +21,8 @@ export default class ItemView { */ constructor({ attrs: { controller, onDelete } }) { this.controller = controller; - this.data = this.controller.data; this.handler = this.controller.handler; + this.data = this.controller.data; this.resource = this.controller.resource; if (!onDelete) this.onDelete = () => { m.route.set(`/${controller.resource}`); }; else this.onDelete = onDelete; @@ -51,6 +51,9 @@ export default class ItemView { layout(children) { if (!this.controller || !this.controller.data) return ''; + // update the reference to the controller data, as this may be refreshed + // in between + this.data = this.controller.data; return m('div', [ m(Toolbar, m('div.pe-button-row', [ m(Button, {