venkat7668
venkat7668

Reputation: 2767

How to stop EmberJs from change hash URL

I have a user submission form if user make any changes in the form, user should submit form to save the change in persistent data base. Page has other links, when user clicks on the link without submission the changes. I have to stop the user to redirection and show the modal box message to convey the message.

I tried below method but does not work.

    App.FormRoute = Ember.Route.extend({
       actions: {
          willTransition: function(transition) {
            if (this.controller.get('userHasEnteredData')) {
               transition.abort();
            }
        }
    }
});

Upvotes: 0

Views: 159

Answers (1)

Daniel
Daniel

Reputation: 18672

Your solution works fine, you can see working demo. Just make sure haven't misspelled any variable name during set in controller or read in form route.

Upvotes: 2

Related Questions