Skip to content

Commit 0b5d9ab

Browse files
committed
fix: salvataggio registrazioni
1 parent 1bdabc0 commit 0b5d9ab

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

plugins/registrazioni/edit.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,25 @@ function validateConti() {
225225
226226
// Gestione del reset del conto quando si cambia lo stato del cespite
227227
$(document).ready(function() {
228+
// Verifica che Parsley sia disponibile
229+
if (typeof window.Parsley === \'undefined\') {
230+
return;
231+
}
232+
228233
// Aggiungi validazione personalizzata solo se siamo nel plugin registrazioni
229234
if (window.location.href.indexOf(\'id_plugin=<?php echo $id_plugin; ?>\') > -1 &&
230235
$(\'input[name="op"][value="change-conto"]\').length > 0) {
231236
232237
// Override del submit del form SOLO per il plugin registrazioni
233238
$(\'form[action=""]\').off(\'submit.registrazioni\').on(\'submit.registrazioni\', function(e) {
234239
// Prima validazione Parsley standard
235-
if (!$(this).parsley().validate()) {
236-
return false;
240+
try {
241+
const parsleyInstance = $(this).parsley();
242+
if (parsleyInstance && typeof parsleyInstance.validate === \'function\') {
243+
if (!parsleyInstance.validate()) {
244+
return false;
245+
}
246+
}
237247
}
238248
239249
// Poi validazione personalizzata per i conti
@@ -289,7 +299,15 @@ function validateConti() {
289299
}
290300
291301
// Aggiorna la validazione Parsley
292-
$(\'form\').parsley().refresh();
302+
try {
303+
const form = $(\'form[action=""]\');
304+
if (form.length > 0 && form.parsley && typeof form.parsley === \'function\') {
305+
const parsleyInstance = form.parsley();
306+
if (parsleyInstance && typeof parsleyInstance.refresh === \'function\') {
307+
parsleyInstance.refresh();
308+
}
309+
}
310+
}
293311
});
294312
295313
// Gestione del cambio di selezione nei conti per rimuovere errori

0 commit comments

Comments
 (0)