-4

So I have searched the web up and down and can't find anything about this. Basically I have tried many different times to use the afterModel hook in routes to no avail because it hangs the application.

First use case was to prevent users from going to routes that were not permissible during certain situations. This worked fine, I aborted the transition no problem. The problem is when the conditions of those if statements are NOT true and the hook is expected (by me) to just exit and then render the page. Nothing happens. Just sits there forever.

This is something where doesn't matter what code I have in there, it simply does not work.

This:

afterModel: function(model, transition) {
},

Locks up the app. I could find nothing on any tutorial or definition of afterModel that specifies requiring you to return anything though I've seen examples where they've returned something.

beforeModel doesn't have this problem.

Alex
  • 121
  • 11
  • 3
    here's a twiddle showing this is untrue: https://ember-twiddle.com/099163dbf90b9b091c143217ae32feae?openFiles=templates.application.hbs%2C – runspired May 24 '17 at 00:57
  • And always call `this._super(...arguments)`. – Lux May 24 '17 at 11:20
  • So when I call `this._super(model, transition)` it seems to work. @Lux .. But in @runspired's Twiddle he doesn't call that and his still works. – Alex May 24 '17 at 14:25
  • @Lux your comment should be the answer btw. :) it IS the answer. – Alex May 24 '17 at 14:25
  • Thanks for the Twiddle @runspired – Alex May 24 '17 at 14:38
  • @AlexanderRose is your route a subclass of another route or using a mixin? – runspired May 25 '17 at 04:44
  • @runspired, I think it's a mixin.. here's the declaration `export default Ember.Route.extend(AuthenticatedRouteMixin, { ... }` – Alex May 26 '17 at 13:15
  • Really confused as why this question has a -4 rep. – Alex May 31 '17 at 15:49
  • May be you might provide concrete minimum verifiable problems. which will clarify that `afterModel` locks up. but to prove that's wrong there is twiddle shared by runspired. That might be the reason for downvote. May be downvoters are not convinced as there is no problem exists with afterModel hook. – Ember Freak Jun 22 '17 at 14:06
  • Yeah Twiddles that are empty applications with zero code in them. Of course they work. I shouldn't be punished because my project doesn't work. Just makes me want to cease participation. Not only that but the answers are provided in this as comments instead of answers, and they solve my problem, but instead of this question being 'resolved' it gets downvoted. – Alex Jun 22 '17 at 16:26
  • Meanwhile I can't really do anything because I don't have enough reputation. It's elitist culture at its best. – Alex Jun 22 '17 at 16:28
  • Another example of this: https://stackoverflow.com/questions/42491567/inadequate-ecmascript-6-es6-support-for-enide-eclipse-unexpected-token-for#42514518 ... I am having same issue in Eclipse. No one answered the question, and it got downvoted why. It's something that happens I'm having same issue yet that was unable to help me in any way. Now had someone answered that question it would be helpful to others. – Alex Jun 23 '17 at 17:00
  • And this is why loss of reputation is a problem, and reliance on such a stupid elitist old-world forum idea is dumb: https://stackoverflow.com/questions/32975385/action-bubbling-in-ember .. guy says sendAction is the old (pre 2.0) way of doing things. So naturally I want to comment and ask why the OFFICIAL EMBER DOCUMENTATION explicitly says how you call actions if it's not how you do it anymore, and yet I cannot. So me and that dude cannot communicate. It's the ONLY place I have seen ANYWHERE on the web that says ANYTHING about sendAction being old, and my communication with him is shut down. – Alex Jun 23 '17 at 21:53

1 Answers1

0

By putting this._super(model, transition) into the afterModel hook this stops locking up.

I think it has something to do with it using ember-simple-auth addon which requires using a mixin on pages that use the addon.

Alex
  • 121
  • 11