Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added jquery for radio buttons

  • Loading branch information...
commit c4eff26cf0e735a7529530fff82cfe1449b1b6bc 1 parent 11db74a
@eweiser authored
Showing with 24 additions and 3 deletions.
  1. +18 −0 static/scripts/radio_buttons.js
  2. +6 −3 templates/index.html
View
18 static/scripts/radio_buttons.js
@@ -0,0 +1,18 @@
+jQuery(function($) {
+ $('div.btn-group[data-toggle-name=*]').each(function(){
+ var group = $(this);
+ var form = group.parents('form').eq(0);
+ var name = group.attr('data-toggle-name');
+ var hidden = $('input[name="' + name + '"]', form);
+ $('button', group).each(function(){
+ var button = $(this);
+ button.live('click', function(){
+ hidden.val($(this).val());
+ });
+ if(button.val() == hidden.val()) {
+ button.addClass('active');
+ }
+ });
+ });
+});
+
View
9 templates/index.html
@@ -4,6 +4,9 @@
<title>Settle Princeton</title>
<link href='//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css' rel='stylesheet' />
<link href='/static/style.css' rel='stylesheet' />
+ <script src='/static/jquery.js'></script>
+ <script src='/static/scripts/radio_buttons.js'></script>
+ <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
</head>
<body>
<h1>Settle Princeton</h1>
@@ -15,9 +18,9 @@
<input class='span3' name='phone' id='phone' type='text'>
<label>3 or 4 players?</label>
<div class="btn-group" data-toggle-name="is_private" data-toggle="buttons-radio" >
- <button type="button" value="0" class="btn" data-toggle="button">3</button>
- <button type="button" value="1" class="btn" data-toggle="button">4</button>
- <button type="button" value="2" class="btn" data-toggle="button">I don't care</button>
+ <button type="button" value="3" class="btn" data-toggle="button">3</button>
+ <button type="button" value="4" class="btn" data-toggle="button">4</button>
+ <button type="button" value="0" class="btn" data-toggle="button">I don't care</button>
</div>
<input type="hidden" name="is_private" value="0" />
<br /><br />
Please sign in to comment.
Something went wrong with that request. Please try again.