Correzioni minori sugli input JS

This commit is contained in:
Dasc3er 2020-10-05 13:38:50 +02:00
parent f0c3f12ea4
commit a0b421b615
1 changed files with 20 additions and 6 deletions

View File

@ -21,11 +21,19 @@ function input(name) {
}
function Input(name) {
this.element = $("[name='" + name + "']").last();
// Selezione tramite jQuery
if (name instanceof jQuery) {
this.element = name.last();
}
// Fix per select multipli
if (this.element.length === 0) {
this.element = $("[name='" + name + "[]']").last();
// Selezione per nome
else {
this.element = $("[name='" + name + "']").last();
// Fix per select multipli
if (this.element.length === 0) {
this.element = $("[name='" + name + "[]']").last();
}
}
// Controllo sulla gestione precedente
@ -99,7 +107,7 @@ Input.prototype.getData = function () {
}
return {
value: this.element.val()
value: this.get()
};
}
@ -108,10 +116,16 @@ Input.prototype.get = function () {
// Conversione del valore per le checkbox
let group = this.element.closest(".form-group");
if (group.find("input[type=checkbox]").length){
if (group.find("input[type=checkbox]").length) {
value = parseInt(value) ? 1 : 0;
}
// Gestione dei valori numerici
const autonumeric = this.element.data("autonumeric");
if (autonumeric) {
value = parseFloat(autonumeric.rawValue);
}
return value;
}