From c7c46d2b7ba864432369ea240445a46ab9eb3d0c Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez <gonzalo@wyeworks.com> Date: Wed, 7 Dec 2011 01:55:23 -0200 Subject: [PATCH] Update edit form after aspect rename. Closes #2363. --- app/controllers/aspects_controller.rb | 2 +- public/javascripts/aspect-edit-pane.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 942e95a7bf..d9268c7e99 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -118,7 +118,7 @@ class AspectsController < ApplicationController else flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name end - render :nothing => true, :status => 204 + render :json => { :name => @aspect.name } end def toggle_contact_visibility diff --git a/public/javascripts/aspect-edit-pane.js b/public/javascripts/aspect-edit-pane.js index 7298be4808..f179c1561a 100644 --- a/public/javascripts/aspect-edit-pane.js +++ b/public/javascripts/aspect-edit-pane.js @@ -8,12 +8,18 @@ function toggleAspectTitle(){ $("#aspect_name_edit").toggleClass('hidden'); } +function updateAspectName(new_name) { + $('#aspect_name_title .name').html(new_name); + $('input#aspect_name').val(new_name); +} + $(document).ready(function() { $('#rename_aspect_link').live('click', function(){ toggleAspectTitle(); }); - $(".edit_aspect").live('ajax:success', function(data, json, xhr) { + $('form.edit_aspect').live('ajax:success', function(evt, data, status, xhr) { + updateAspectName(data['name']); toggleAspectTitle(); }); }); -- GitLab