From f135e978f8dc24510c43dce6484adab4c8291e6d Mon Sep 17 00:00:00 2001 From: tofulm Date: Fri, 13 Jan 2023 12:06:38 +0100 Subject: [PATCH] Feat: ajout du url_action --- src/gamutable.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/gamutable.js b/src/gamutable.js index 1a27c41..1d013a0 100644 --- a/src/gamutable.js +++ b/src/gamutable.js @@ -37,3 +37,45 @@ for (const el of document.getElementsByClassName('vue-gamutable')) { } i++; } + +$('#vueGamutable').on('click', '.url_action', function (e) { + console.log('coucou'); + e.preventDefault(); + e.stopPropagation(); + let confirmation = $(this).data('confirm'); + if (confirmation !== undefined) { + if (!confirm(confirmation)) { + return; + } + } + let url = $(this).attr('href'); + let id = $(this).data('id'); + // passer en refresh animé une éventuelle icone + if ($(this).has('i.icon, i.fa')) { + $(this).find('i.icon, i.fa').eq(0).replaceWith(''); + } + let nomBlocAjaxReload = $(this).data('ajaxreload'); + console.time('Chargement de VueJs APRES Ajax'); + $.ajax({ + url: url, + dataType: 'json', + async: true, + }).done(function (retour) { + if (!$.isEmptyObject(retour) && !$.isEmptyObject(retour.message_erreur)) { + alert(retour.message_erreur); + } else { + if (parseInt(id) > 0) { + app.rechargerJson(id); + } else { + app.rechargerJson(); + } + if (nomBlocAjaxReload !== undefined) { + console.log('depart reload: ' + nomBlocAjaxReload); + ajaxReload(nomBlocAjaxReload, { + args: { id }, + callback: function () {}, + }); + } + } + }); +});