Skip to content

Instantly share code, notes, and snippets.

@SuperCoolFrog
Last active January 25, 2017 14:56
Show Gist options
  • Save SuperCoolFrog/03825ecbcf0ae48f940db926594a58c9 to your computer and use it in GitHub Desktop.
Save SuperCoolFrog/03825ecbcf0ae48f940db926594a58c9 to your computer and use it in GitHub Desktop.
After Model Not Hit
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
goTo() {
this.transitionToRoute('food');
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('food', function() {
this.route('options');
this.route('fruits');
this.route('veggies');
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {},
afterModel() {
this.transitionTo('food.options');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
transitionTo(r) {
this.transitionTo(r);
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
Reproduction Steps:
<ol>
<li>
Click Food Options Button:
</li>
<li>
Notice it hits the afterModel in food route and redirects(expected behavior)
</li>
<li>
Clicking the button again will not hit after model(unexpected behavior)
</li>
<li>
If you click on any of the sub routes and then click on food options it also will not hit the afterModel (unexpected behavior)
</li>
</ol>
<hr>
<br>
<br>
<button onclick={{action 'goTo'}}>Food Options</button>
<br>
{{outlet}}
<br>
<br>
Fruits:
<ul><li>Orange</li></ul>
<h3>Food</h3>
<hr>
{{outlet}}
<button onclick={{action send 'transitionTo' 'food.veggies'}}>Veggies</button><br>
<button onclick={{action send 'transitionTo' 'food.fruits'}}>Fruits</button>
Veggies:
<ul><li>Carrot</li></ul>
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment