-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Ability to prevent switching inside event handler #268
Comments
+1. I was looking for this functionality so I can first display a confirmation to the user before unchecking a particular option that is very important. |
@daverogers @raveren i opened a branch for it, but it will take some time since it requires many parts to be rewritten. |
+1 from me. This would be a great improvement! Looking forward to this |
+1. It would be a huge help. Like @daverogers, I need to a confirmation modal too. |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Can anyone give me feedback before merging this commit in master? 61b2289 |
Works for me! Thanks for the add. For those looking for how to implement... var options = {
onSwitchChange: function(event, state) {
// Return false to prevent the toggle from switching.
return false;
}
};
$('[name="my-checkbox"]').bootstrapSwitch(options); Then when you want to programmatically toggle the switch: $('[name="my-checkbox"]').bootstrapSwitch('toggleState', true); The Hope that helps. |
Thanks @mgoldsborough for these lines of documentation ;) I need to talk with @LostCrew in order to decide when and how to release this feature. |
With @LostCrew , we decided to refactor a little bit the code, anyway this will be released in the 3.3.3 version. |
@mgoldsborough I got the release 3.3.2. |
@fuvizzo this functionality is not yet released. @nostalgiaz @LostCrew, any updates on when v3.3.3 (or 3.4.0) will be tagged and released? |
@mgoldsborough is it ready for production? |
Badly need this functionality. When would it be released |
@nostalgiaz Yes, I think so? It's working for me. I'd reco a tag/release. Thanks. |
+1 need this released |
@OakBehringer here we go... the code is in master. |
Awesome - thanks! |
I take it back. bootstrap-switch.js and bootstrap-switch.min.js haven't been changed for 2 months. Same with the coffee scripts. ??? |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 |
Hasn't this been implemented yet? |
Bump Has this been implemented yet? Sample code from @mgoldsborough over a year ago doesn't seem to work. My problem is I have a read-only page with labels and the switch is disabled but users can click on the label to toggle the switch. Check this jsfiddle. As a side note, if you add the Edit: Stupid me...pending label is set. |
In my case I added a transparent DIV over the switch button, then I change the switch state on a click event. This disabled the slide functionality, but it solved my problem :) |
I don't really need this at the moment, this is just for uniformity, other high quality jquery plugins usually implement some way to prevent user from performing actions in event callbacks:
Returning
false
from event handler would also stop propagation, but in this case, when switches never contain other switches, that's irrelevant.The text was updated successfully, but these errors were encountered: