From 71c53e184e4a94f6f9f6aec315b239f2a6420621 Mon Sep 17 00:00:00 2001 From: Lucas Wiersma Date: Wed, 13 May 2020 14:13:17 +0200 Subject: [PATCH] use the utils method hideOrShow to set the initial state of the items on init (same as on change) this will add the class visible on items that should be shown and hidden on items that should be hidden. Hence the behaviour will work on initial load. --- src/pat/depends/depends.js | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/pat/depends/depends.js b/src/pat/depends/depends.js index 3aeaddc20..1151d8090 100644 --- a/src/pat/depends/depends.js +++ b/src/pat/depends/depends.js @@ -45,14 +45,11 @@ define([ log.error("Invalid condition: " + e.message, slave); return; } - state=handler.evaluate(); switch (options.action) { case "show": - if (state) - this.show(); - else - this.hide(); + utils.hideOrShow($el, state, options, this.name); + this.updateModal(); break; case "enable": if (state) @@ -62,10 +59,12 @@ define([ break; case "both": if (state) { - this.show(); + utils.hideOrShow($el, state, options, this.name); + this.updateModal(); this.enable(); } else { - this.hide(); + utils.hideOrShow($el, state, options, this.name); + this.updateModal(); this.disable(); } break; @@ -112,16 +111,6 @@ define([ } }, - show: function () { - this.$el.show(); - this.updateModal(); - }, - - hide: function () { - this.$el.hide(); - this.updateModal(); - }, - enable: function() { if (this.$el.is(":input")) this.$el[0].disabled=null;