Skip to content

Instantly share code, notes, and snippets.

@rtablada
Last active June 26, 2018 18:30
Show Gist options
  • Save rtablada/095e782d1273d1cc662d1a4eabafb03a to your computer and use it in GitHub Desktop.
Save rtablada/095e782d1273d1cc662d1a4eabafb03a to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('no', { path: '/:id' })
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
afterModel({ id }, transition) {
if (id == 2) {
// What to do when the transition is from a URL/location change
// Not transitionTo
if (transition.sequence === 0) {
return this.transitionTo('index');
}
transition.abort();
}
}
});
{{#link-to "no" 1}}Try 1{{/link-to}}
{{#link-to "no" 2}}Try 2{{/link-to}}
<p>The Page should abort if try 2</p>
<p>How do you check if transition is from URL vs router transitions</p>
{
"version": "0.14.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"ember-data": "2.18.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment