Skip to content

Instantly share code, notes, and snippets.

@mvschaik
Last active December 18, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvschaik/5782169 to your computer and use it in GitHub Desktop.
Save mvschaik/5782169 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<link rel="stylesheet" href="bootstrapSwitch.css">
</head>
<div>
As taken from the examples: <br>
<div id="disable-switch" class="switch">
<input type="checkbox" checked />
</div>
<br>
<button id="btn-disable-switch" class="btn">
Disable!
</button>
<button id="btn-activate-switch" class="btn">
Activate!
</button>
</div>
<div>
Same but with id tag on input. Will still be usable after disable:<br>
<div id="disable-switch-fail" class="switch">
<input id="confused" type="checkbox" checked />
</div>
<br>
<button id="btn-disable-switch-fail" class="btn">
Disable!
</button>
<button id="btn-activate-switch-fail" class="btn">
Activate!
</button>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script src="bootstrapSwitch.js"></script>
<script>
$('#btn-disable-switch').on('click', function () {
$('#disable-switch').bootstrapSwitch('setActive', false);
});
$('#btn-activate-switch').on('click', function () {
$('#disable-switch').bootstrapSwitch('setActive', true);
});
$('#btn-disable-switch-fail').on('click', function () {
$('#disable-switch-fail').bootstrapSwitch('setActive', false);
});
$('#btn-activate-switch-fail').on('click', function () {
$('#disable-switch-fail').bootstrapSwitch('setActive', true);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment