Skip to content

Instantly share code, notes, and snippets.

@darthdeus
Created February 3, 2013 13:31
Show Gist options
  • Save darthdeus/4701799 to your computer and use it in GitHub Desktop.
Save darthdeus/4701799 to your computer and use it in GitHub Desktop.
Scvrush.UserEditRoute = Ember.Route.extend({
events: {
saveProfile: function() {
var user = this.controllerFor("user").get("content"),
route = this;
user.one("didUpdate", function() {
route.transitionTo("home");
});
user.get("transaction").commit();
}
},
enter: function() {
var user = this.controllerFor("user").get("content"),
transaction = user.get("store").transaction();
transaction.add(user);
},
exit: function() {
this.controllerFor("user").get("content.transaction").rollback();
},
});
@akshayrawat
Copy link

Scvrush.UserEditRoute = Ember.Route.extend({
  model: {
    return this.modelFor('user');
  },

  events: { 
  saveProfile: function(user) {
     var route = this;

     user.on("didUpdate", function() {
        route.transitionTo("home");
     });

    user.get("transaction").commit();
  }

},

enter: function() {
  //not sure if currentModel if available at this point. But it usually is later.
  var user = this.currentModel;
  transaction = user.get("store").transaction();

  transaction.add(user);
},

  exit: function() {
    this.currentModel.get("content.transaction").rollback();
  },

  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment