mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Iniciado detector de cambios en presupuesto
This commit is contained in:
@ -82,13 +82,12 @@
|
||||
id: 'id',
|
||||
text: 'nombre',
|
||||
searchTerm: params.term,
|
||||
<
|
||||
? = csrf_token() ?? "token" ? > : < ? = csrf_token() ? > v
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
};
|
||||
},
|
||||
delay: 60,
|
||||
processResults: function(response) {
|
||||
yeniden(response. < ? = csrf_token() ? > );
|
||||
yeniden(response.<?= csrf_token() ?>);
|
||||
return {
|
||||
results: response.menu
|
||||
};
|
||||
@ -112,6 +111,49 @@
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<!------------------------------------------------------->
|
||||
<!-- Código JS para detectar cambios en el presupuesto -->
|
||||
<!------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
// Obtener todos los campos de entrada del formulario
|
||||
const formInputs = document.querySelectorAll('input, textarea');
|
||||
|
||||
//console.log(formInputs)
|
||||
|
||||
// Crear un objeto para almacenar los valores originales
|
||||
const originalValues = {};
|
||||
|
||||
// Guardar los valores originales
|
||||
formInputs.forEach(function(input) {
|
||||
originalValues[input.id] = input.type === 'checkbox' ? input.checked : input.value;
|
||||
});
|
||||
|
||||
// Agregar un evento de cambio a cada campo de entrada
|
||||
formInputs.forEach(function(input) {
|
||||
console.log(input.type)
|
||||
input.addEventListener('input', function() {
|
||||
//console.log(input.value)
|
||||
// Verificar si hay cambios con respecto a los originales
|
||||
const cambiosDetectados = Array.from(formInputs).some(function(input) {
|
||||
return input.type === 'checkbox' ?
|
||||
input.checked !== originalValues[input.id] :
|
||||
input.value !== originalValues[input.id];
|
||||
});
|
||||
|
||||
// Mostrar alerta solo si hay cambios
|
||||
if (cambiosDetectados) {
|
||||
showBreadCrumbSaveButton(true);
|
||||
console.log('¡Se detectaron cambios!');
|
||||
}else{
|
||||
showBreadCrumbSaveButton(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<!------------------------------------------->
|
||||
<!-- Acciones antes de submit... -->
|
||||
<!------------------------------------------->
|
||||
|
||||
Reference in New Issue
Block a user