Ember is adding a ?
to the URL on transition that causes a complete, unwanted page refresh when transitioning to a parent route. I have a route structure like so.
App.Router.map(function() {
this.resource('settings', function() {
this.route('profile');
});
});
App.SettingsRoute = RestrictedRoute.extend(AccountFinder, {
controllerName: 'account',
renderAccountTemplate: function(controller, model) {
this.render('settings', {controller: controller});
},
});
App.SettingsProfileRoute = Ember.Route.extend({
actions: {
willTransition: function() {
var account = this.modelFor('settings'), confirmed;
if (account.get('customIsDirty')) {
confirmed = confirm("You have blah changes. Do you want to continue?");
if (!confirmed) {
transition.abort();
} else {
account.customRevert();
}
}
}
}
cancelEditing: function() {
var model = this.modelFor('settings');
account.revert();
this.transitionTo('settings', account);
},
});
This is a non-Ember Data model setup. When my modelās customIsDirty
property is false
(meaning no confirm stuff happens and basically willTransiition
is ignored), ember transitions back to the settings
route and adds a ?
to the URL, causing the page to immediately reload.
When my modelās customIsDirty
property returns true
, causing the native confirm
functionality, accepting the confirm dialog (which obviously allows the transition to occur because there is no abort
call) transitions to the settings
route and does not add the ?
to the URL or cause a page refresh.
What the MF is going on here? This shouldnāt have anything to do with my custom model setup, as I am doing nothing in the willTransition
method that messes with the transition, nor am I transitioning to a route with any type of additional query-params-new
(or whatever the feature is) stuff. Itās a simple call to cancelEditing
in both cases.
I also never, in the entire app, mess with window.location
. Also, this happens with every version from 1.1.0
on. (1.0.0
is apparently not compatible with my app).
If it matters, I am using ember-ohm as my model layer.