Feat: ajout du url_action

This commit is contained in:
Christophe 2023-01-13 12:06:38 +01:00
parent d40343e2cc
commit f135e978f8

View file

@ -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('<i class="fa fa-refresh fa-spin"></i>');
}
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 () {},
});
}
}
});
});