Knockout Binding Handler for the bootstrap-toggle plugin.
bower install knockout-bootstrap-toggle
Include the javascript file in your html:
<script src="/bower_components/knockout/dist/knockout.js"></script>
<script src="/bower_components/bootstrap-toggle/js/bootstrap-toggle.js"></script>
<script src="/bower_components/knockout-bootstrap-toggle/ko.bindingHandlers.bootstrapToggle.js"></script>
Add an bootstrapToggle
data binding to the checkbox:
<input type="checkbox" data-toggle="toggle" data-bind="bootstrapToggle: wantsSpam" />
Use like a normal checkbox (http://knockoutjs.com/documentation/checked-binding.html)
var viewModel = {
wantsSpam: ko.observable(true) // Initially checked
};
// ... then later ...
viewModel.wantsSpam(false); // The checkbox becomes unchecked