Update edit form after aspect rename. Closes #2363.

This commit is contained in:
Gonzalo Rodriguez 2011-12-07 01:55:23 -02:00
parent beeb02dcd6
commit c7c46d2b7b
2 changed files with 8 additions and 2 deletions

View file

@ -118,7 +118,7 @@ class AspectsController < ApplicationController
else else
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
end end
render :nothing => true, :status => 204 render :json => { :name => @aspect.name }
end end
def toggle_contact_visibility def toggle_contact_visibility

View file

@ -8,12 +8,18 @@ function toggleAspectTitle(){
$("#aspect_name_edit").toggleClass('hidden'); $("#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() { $(document).ready(function() {
$('#rename_aspect_link').live('click', function(){ $('#rename_aspect_link').live('click', function(){
toggleAspectTitle(); 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(); toggleAspectTitle();
}); });
}); });