Skip to content

How to update value when model data is updated. #6

@dirkdirk

Description

@dirkdirk

I have a route that displays a simditor editor. It loads fine the first time the route is called, but when the model's data changes, the editor's value does not change.

app/router.js

  this.route('items', function() {
    this.route('item', {path: ':item_id'});
  });

app/routes/items/item.js

  model(params) {
      return this.store.findRecord('item', params.item_id);
  }

app/templates/items/item.hbs

{{simditor-editor value=(mut model.text)
                  update=(action (mut model.text))
                  toolbar=simditorOptions.toolbar
                  editor=(mut editor)
                  onValuechanged=(action 'saveItemSlow')
                  onBlur=(action 'saveItemNow')  }}

Rendering localhost:4200/items/3 displays the text for item_id 3 in the Simditor editor as expected. But then going directly to localhost:4200/items/7 still displays the text for item_id 3.

If instead, one goes to localhost:4200/items and then to localhost:4200/items/7, the text for item_id 7 is displayed in Simditor as expected.

I suspect it has to do with Simditor not being destroyed when staying on the items/item_id route. Changing routes and going back to the items/items_id route, destroys the component and rerenders it.

Is there a way to manually destroy all instances of Simditor on some hook like beforeModel? And then manually force the component to rerender?

Or is there another / better solution?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions