Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modelFor return undefined, in deactivate route event #727

Open
rakesh5208 opened this issue Aug 16, 2020 · 2 comments
Open

modelFor return undefined, in deactivate route event #727

rakesh5208 opened this issue Aug 16, 2020 · 2 comments

Comments

@rakesh5208
Copy link

I have an ember app, and here is the routing for messages

this.route('messages', function() {
   this.route('list');
   this.route('new');
   this.route('edit');
});

in the messages.list route, while deactivating the route, following code snippet is running,

discardFilter: on('deactivate', function() {
    let model = this.modelFor('messages.list');
    set(model, 'filterUnstable', false);
  }),
model() {
    return RSVP.hash({
      contacts: get(this, 'store').findAll('message'),
      filterUnstable: true
    });
  }

here, on discardFilter, this.modelFor('messages.list'); return the object from model hook.

the same app, i am converting the messages to the engines, in the host app, mounting the route as
this.mount('message-engine', {as: "messages"});,
and inside the engines building the route as following:

export default buildRoutes(function() {
    this.route('list');
    this.route('new');
    this.route('edit');
});

and inside the routes/list, while deactivating the routes, the same code snippet return undefined, below is the code snippet,

discardFilter: on('deactivate', function() {
    **let model = this.modelFor('list');** // _return undefined here_
    set(model, 'filterUnstable', false);
  }),
  model() {
    return RSVP.hash({
      messages: get(this, 'store').findAll('message'),
      filterUnstable: true
    });
  }

Node and ember version

node: 8.16.0,
npm: 6.4.1,
ember-cli: 2.15.1,
ember-data: 2.15.4
@rakesh5208
Copy link
Author

while debugging, i have found inside the message engines Ember.getOwner(this).lookup("route:messages.list") return undefined, while Ember.getOwner(this).lookup("route:list") return the router instance object.

modeFor in the route.js, have same prefixed with the mounting path name, cause the lookup instance to return undefined.

@ezy
Copy link

ezy commented Mar 16, 2021

See emberjs/ember.js#17419 for related info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants