From 466322ba544b5469e8eec432fa88b0b563b4c4dd Mon Sep 17 00:00:00 2001 From: Dasc3er Date: Tue, 21 Sep 2021 15:44:47 +0200 Subject: [PATCH] Correzione set JS per checkbox disabilitati --- assets/src/js/functions/input.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/assets/src/js/functions/input.js b/assets/src/js/functions/input.js index 67ada7e22..201b886bd 100644 --- a/assets/src/js/functions/input.js +++ b/assets/src/js/functions/input.js @@ -287,8 +287,6 @@ Input.prototype.get = function () { * @returns {Input} */ Input.prototype.set = function (value) { - const previous = this.get(); - // Gestione dei valori per l'editor if (this.element.hasClass("editor-input") && typeof CKEDITOR !== 'undefined') { const name = this.element.attr("id"); @@ -298,9 +296,10 @@ Input.prototype.set = function (value) { // Impostazione valore per checkbox let group = this.element.closest(".form-group"); - const checkbox = group.find("input[type=checkbox]"); - if (checkbox.length && parseInt(value) !== previous) { - checkbox.click(); + if (group.find("input[type=checkbox]").length) { + value = value === true || parseInt(value) !== 1; + group.find("[type=hidden]").val(+value).trigger('change') + group.find("[type=checkbox]").prop("checked", value); } }