Created
December 18, 2012 21:38
-
-
Save clouddueling/4332275 to your computer and use it in GitHub Desktop.
Use buttons for radio inputs. What mine look like: http://screencloud.net/v/EeMb
Source: http://dan.doezema.com/2012/03/twitter-bootstrap-radio-button-form-inputs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='row-fluid'> | |
<div class='span12'> | |
<div data-toggle-name='record_id' value='Hank Williams' class='btn btn-input btn-large'> | |
Hank Williams | |
</div> | |
<div data-toggle-name='record_id' value='Cee Lo Green' class='btn btn-input btn-large'> | |
Cee Lo Green | |
</div> | |
<input type='hidden' name='record_id' value='0'> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("div.btn-input").live('click', function(){ | |
var btn = $(this), | |
container = btn.parent(), | |
name = btn.data('toggle-name'), | |
hidden = container.find('input[name="' + name + '"]'), | |
value = btn.attr('value'); | |
hidden.val(value); | |
container.find(".btn-input").removeClass('active btn-primary'); | |
btn.addClass('active btn-primary'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment