
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 1.16 KB | hits: 24 | expires: Never
var App = App || {};
App.Controllers = App.Controllers || {};
App.Controllers.UserEdit = function() {
this.model = new App.Models.Users();
this.view = new App.Views.UserEdit();
App.Routes.addRoute("/users/:user_uuid/edit/", $.proxy(this.handleUserEditRoute, this));
// This is a little jQuery plugin that provides custom events
$.subscribe("UserEditFormSubmitted", $.proxy(this.handleFormSubmitted, this));
}
App.Controllers.UserList.prototype.handleUserEditRoute = function(params) {
this.model.getRecord({uuid: params.user_uuid, success: $.proxy(this.renderUserEditView, this)})
}
App.Controllers.UserList.prototype.renderUserEditView = function(response) {
this.view.render(response);
}
App.Controllers.UserList.prototype.handleFormSubmitted = function(formData) {
var formDataObject = stringToObj(formData); // this function just turns "some=value&someOther=value2" into {some: "value", someOther: "value2"}
this.model.updateRecord({
uuid: formDataObject.uuid,
data: formData,
success: $.proxy(this.handleUpdateSuccess, this)
});
}
App.Controllers.UserList.prototype.handleUpdateSuccess = function(response) {
document.location.hash = "/users/";
}