jquery - Bootstrap switch working with only one state -
i using bootstrap switch library after writing following code, i'm able pass 'true/yes/on' value backend. other state not being passed @ all.
html:
<input type="checkbox" name="anonymous" checked>
javascript:
<script> $("[name='anonymous']").bootstrapswitch({ state:false, size:'mini', ontext:'yes', offtext:'no', offcolor:'primary', oncolor:'danger' }); </script>
what missing or doing wrong?
your example isn't 100% clear enough illustrate potential problem be, state
should return correct element state.
$("[name='anonymous']").on('switchchange.bootstrapswitch', function (event, state) { console.log(state); });
the code provided instantiates element, need make use of change event / make sure read new value on whatever submit function you're using.
Comments
Post a Comment