Related to: http://www.bootstraptoggle.com/
Is there any way to set checked state without raising onchange
event?
It's simpler to explain with an example
<input type="checkbox" data-toggle="toggle" data-on="Active" data-off="Disabled" data-width="100px" id="chb_nueva_ruta">
<script type="text/javascript">
$("#chb_nueva_ruta").on("change", function () {
alert('You click it manually');
});
</script>
When the user clicks on the check box, an alert is shown. However, for an out of question reason, I need to change the state of the checkbox in other function, but I don't want the code defined on the onchange event be executed.
According to documentation, for change the state I should use: $("#chb_nueva_ruta").bootstrapToggle('off')
But that line of code, raises onchange event. If I simply do $("#chb_nueva_ruta").attr("checked", false)
The checkbox stills showing to the user like if it's checked.
Aucun commentaire:
Enregistrer un commentaire