From 11b544bb73e0e68dfeeec4f71f329bc98676f585 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 2 Oct 2015 00:31:51 +0200 Subject: [PATCH] lib: allow change value through js only in case skip is true as we won't fire event, we allow to change that value to display the switcher as it should --- .../static/lib/bootstrap-switch/README.md | 3 ++- .../static/lib/bootstrap-switch/bootstrap-switch.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/web_widget_boolean_switch/static/lib/bootstrap-switch/README.md b/web_widget_boolean_switch/static/lib/bootstrap-switch/README.md index 8cd08298..6a84a345 100644 --- a/web_widget_boolean_switch/static/lib/bootstrap-switch/README.md +++ b/web_widget_boolean_switch/static/lib/bootstrap-switch/README.md @@ -8,4 +8,5 @@ directories at this [revision](https://github.com/nostalgiaz/bootstrap-switch/ tree/a39a1e9d6059822235bf4a9c0e7700a7e6a5ad19/dist) the september 30th 2015. The default library doesn't allow to change value through javascript if -switcher is set `readonly` or `disabled`. +switcher is set `readonly` or `disabled`. We add a small change to +allow it when skip is true. diff --git a/web_widget_boolean_switch/static/lib/bootstrap-switch/bootstrap-switch.js b/web_widget_boolean_switch/static/lib/bootstrap-switch/bootstrap-switch.js index 82c904ea..804c586e 100644 --- a/web_widget_boolean_switch/static/lib/bootstrap-switch/bootstrap-switch.js +++ b/web_widget_boolean_switch/static/lib/bootstrap-switch/bootstrap-switch.js @@ -135,6 +135,9 @@ if (typeof value === "undefined") { return this.options.state; } + if (!skip && (this.options.disabled || this.options.readonly)) { + return this.$element; + } if (this.options.state && !this.options.radioAllOff && this.$element.is(":radio")) { return this.$element; }