I have a checkbox with bootstrap-switch style, when I run the view it creates it with the value "indeterminate", if I execute state
I can change the value to true
or false
, but I can not put it in "indeterminate" as in the beginning. In the examples there is one that does what I want (Indeterminate) which is to return it to "indeterminate" with a button.
$(document).ready(function() {
$.fn.bootstrapSwitch.defaults.onText = 'Si';
$.fn.bootstrapSwitch.defaults.offText = 'No';
$.fn.bootstrapSwitch.defaults.indeterminate = true;
$.fn.bootstrapSwitch.defaults.animate = false;
$('.checkbox_switch').bootstrapSwitch();
});
$(document).on('click', '#si', function() {
$('#crear_neumat').bootstrapSwitch('state' , true);
});
$(document).on('click', '#indeter', function() {
$('#crear_neumat').bootstrapSwitch('state' , null);
});
$(document).on('click', '#no', function() {
$('#crear_neumat').bootstrapSwitch('state' , false);
});
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/css/bootstrap3/bootstrap-switch.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.min.js"></script>
<input type="checkbox" class="checkbox_switch" name="crear_neumat" id="crear_neumat">
<button type="button" id="si" class="btn btn-primary">Si</button>
<button type="button" id="indeter" class="btn btn-primary">Indeterminado</button>
<button type="button" id="no" class="btn btn-primary">No</button>