Skip to content

Instantly share code, notes, and snippets.

@siva-sundar
Last active August 8, 2018 13:13
Show Gist options
  • Save siva-sundar/66df41119ffb0da04255c21c88690344 to your computer and use it in GitHub Desktop.
Save siva-sundar/66df41119ffb0da04255c21c88690344 to your computer and use it in GitHub Desktop.
Transition Abort
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['bool'],
bool: true,
actions: {
toggleQP() {
this.set('bool', !this.get('bool'));
},
gotoApplication() {
this.transitionToRoute('application');
}
}
});
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('my-route');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
bool: {
refreshModel: true
}
},
actions: {
willTransition(transition) {
transition.abort();
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{link-to "go-to-my-route" "my-route"}}
<hr>
{{outlet}}
<br>
<br>
my-route
<hr>
<button {{action "toggleQP"}}> toggle qp </button> => throws maximum call stack due to url change.
<hr>
<button {{action "gotoApplication"}}> go to application route by transition</button> => No maximum call stack exception.
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-data": "3.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment