refresh list when delete type de champ

This commit is contained in:
Tanguy PATTE 2015-11-17 18:52:49 +01:00
parent 1ab89b63aa
commit 41c0ca27d9
4 changed files with 3 additions and 19 deletions

View file

@ -1,14 +0,0 @@
var ready = function () {
$("#liste_champ").on("ajax:success", "div", function(event, data, status, xhr) {
$(event.target).parents('.form-inline').fadeOut("slow", function() {
return $(this).remove();
});
});
};
$(document).ready(ready);
$(document).on('page:load', ready);

View file

@ -4,7 +4,7 @@ class Admin::TypesDeChampController < AdminController
def destroy
@procedure.types_de_champ.destroy(params[:id])
render json: { message: 'deleted' }, status: 200
render 'show', format: :js
rescue ActiveRecord::RecordNotFound
render json: { message: 'Champ not found' }, status: 404
end
@ -14,9 +14,7 @@ class Admin::TypesDeChampController < AdminController
def update
@procedure.update_attributes(update_params)
respond_to do |format|
format.js
end
render 'show', format: :js
end
def update_params

View file

@ -75,7 +75,7 @@ describe Admin::TypesDeChampController, type: :controller do
describe '#destroy' do
before do
delete :destroy, procedure_id: procedure.id, id: type_de_champ_id
delete :destroy, procedure_id: procedure.id, id: type_de_champ_id, format: :js
end
context 'when type de champs does not exist' do
let(:type_de_champ_id) { 99999999 }