From a527cc032d7b5ecbf0d05c58521c5d42047030eb Mon Sep 17 00:00:00 2001 From: Aldarien Date: Wed, 17 Jun 2020 17:01:53 -0400 Subject: [PATCH] FIX: que no aparezca el mensaje cuando funciona --- resources/views/admin/eventos/show.blade.php | 35 +++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/resources/views/admin/eventos/show.blade.php b/resources/views/admin/eventos/show.blade.php index d47fc1e..07fdde2 100644 --- a/resources/views/admin/eventos/show.blade.php +++ b/resources/views/admin/eventos/show.blade.php @@ -219,6 +219,18 @@ ) let data = new FormData(form[0]) let url = '{{$urls->admin}}/evento/{{$evento->id}}/add' + let fallo = () => { + $('#resultado').html('') + $('#resultado').append( + $('
').attr('class', 'ui negative message') + .append($('').attr('class', 'inline close icon')) + .append('

No se pudo agregar.

') + ) + $('#resultado .message .close').on('click', function() { + $(this).closest('.message') + .transition('fade'); + }); + } $.ajax({ url: url, data: data, @@ -228,29 +240,12 @@ success: (output) => { if (output.estado) { window.location.reload() + return } - $('#resultado').html('') - $('#resultado').append( - $('
').attr('class', 'ui negative message') - .append($('').attr('class', 'inline close icon')) - .append('

No se pudo agregar.

') - ) - $('#resultado .message .close').on('click', function() { - $(this).closest('.message') - .transition('fade'); - }); + fallo() }, error: () => { - $('#resultado').html('') - $('#resultado').append( - $('
').attr('class', 'ui negative message') - .append($('').attr('class', 'inline close icon')) - .append('

No se pudo agregar.

') - ) - $('#resultado .message .close').on('click', function() { - $(this).closest('.message') - .transition('fade'); - }); + fallo() } }) },