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.

fiddle


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -