I want to abort transition on a particular route and show a modal. This is how my route code looks like:
export default Ember.Route.extend({
model: {/* some code here */},
actions: {
willTransition: function(transition) {
if (!this.controller.get('model.name')) {
console.log('aborting transition');
transition.abort();
this.send('showModal', {
template: 'campaign/campaign-name-modal',
controller: this.controller,
model: this.controller.get('model')
});
}
else {
// Bubble the `willTransition` action so that
// parent routes can decide whether or not to abort.
return true;
}
}
}
});
and then in my application.hbs
, I have:
{{outlet 'modal'}}
What I am observing is that transition aborts but my modal
doesn't show up. When I switch the ordering to something like:
this.send('showModal', {
template: 'campaign/campaign-name-modal',
controller: this.controller,
model: this.controller.get('model')
});
console.log('aborting transition');
transition.abort();
the transition doesn't abort at all.
I am not exactly sure why this might be happening. Any pointers?
Maybe try editing your conditional to use firstObject:
if (!this.controller.get('model.firstObject.name')) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With