benkingcode / ember-routable-modal

An ember-cli addon for implementing URL-first modals.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Model not found when visiting modal route directly

stephanebruckert opened this issue · comments

When moving from blog.com/articles/5/ to blog.com/articles/5/edit, the modal opens and the model for article with id 5 is found without problem.

When visiting blog.com/articles/5/edit directly, the model is not found unless I look for it myself:

import Ember from 'ember';

import ModalRouteMixin from 'ember-routable-modal/mixins/route';

const { Route } = Ember;

export default Route.extend(ModalRouteMixin, {
  model() {
    return this.store.peekRecord('article', this.router.targetState.routerJsState.params['articles.show'].id);
  }
});

Is this something that could be avoided? Thanks

This has been solved by doing the following in the parent route

  model(params) {
    return this.store.findRecord('inventory', params.id);
  },

instead of

  model(params) {
    return this.store.peekRecord('inventory', params.id);
  },