jquery - Reverting Bootstrap Button Group Click -


i've got bootstrap button group on form, working radio buttons. if user selects 1 of options (in case "single day"), need validation on rest of form. if validation fails, need "unclick" single day - undo radio button selection "multi day" still visually selected.

i've created simple fiddle example w/ 3 solutions i've tried: http://jsfiddle.net/u5ab4/

solution 1 - since it's button group, thought might able toggle group change selection

solution 2 - since group toggle didn't work, maybe need toggle individual buttons?

solution 3 - toggling bust, manually adding/removing active class?

jsfiddle code

html:

<div id="session_type" class="btn-group" data-toggle="buttons-radio">     <button type="button" class="btn">single day</button>     <button type="button" class="btn active">multi day</button> </div> 

js:

$('#session_type > button.btn').on("click", function () {     //attempt 1 - since it's radio button-style button group, thought toggle whole group (ie switch button selected)     $('#session_type').button("toggle");      //attempt 2 - toggle button clicked (ie. single day) unselect (might need toggle other button well, select instead, doesnt work @ all)     //$(this).button("toggle");      //manually add/remove active class each button (again, need add class other button well, doesnt work)     //$(this).removeclass("active"); }); 

i figured out co-workers. example simplified, ended doing toggling button group (solution 1) , adding return false; relevant if statement.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -