Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling/ enabling switch button and turning On and off dynamically #494

Open
rahul44637 opened this issue Jul 22, 2015 · 3 comments
Open

Comments

@rahul44637
Copy link

I m still not able to disable with jquery can u please help.
I want the checkbox switch to get disable, enable and turned on and off dynamically on certain conditions like suppose checked status is true I want to disable the button for a certain period of time lets say 10 min and after that I want it to enable and turned it off again,

Time out function is done but I am not able to disable/enable and turn it on/off.

this is a simple snipet - input id="xyz" type="checkbox" checked

Thanks in advance.

@regepan
Copy link
Contributor

regepan commented Jul 28, 2015

I tried to create what you want to do.
like this?
http:https://jsfiddle.net/regepan/gjq78ydo/1/

If the checkbox has disabled or readonly attribute, bootstrap-switch don't change the checkbox state.
So we need to remove disabled or readonly attribute before change state.

@petrus-v
Copy link

petrus-v commented Oct 2, 2015

Hi!

From my side I've done this little change to allow setting up the element when skipping event:

diff --git a/dist/js/bootstrap-switch.js b/dist/js/bootstrap-switch.js
index 826263a..804c586 100644
--- a/dist/js/bootstrap-switch.js
+++ b/dist/js/bootstrap-switch.js
@@ -135,7 +135,7 @@
         if (typeof value === "undefined") {
           return this.options.state;
         }
-        if (this.options.disabled || this.options.readonly) {
+        if (!skip && (this.options.disabled || this.options.readonly)) {
           return this.$element;
         }
         if (this.options.state && !this.options.radioAllOff && this.$element.is(":radio")) {

then you can set its value element.bootstrapSwitch('state', value, true); even if the element is readonly or disabled.

Probably it should be cleaner to create a new parameter for that!?

Regards

@mister-good-deal
Copy link

@petrus-v you should do a pull request for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants