Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added jquery for radio buttons

  • Loading branch information...
commit c4eff26cf0e735a7529530fff82cfe1449b1b6bc 1 parent 11db74a
Eric Weiser authored

Showing 2 changed files with 24 additions and 3 deletions. Show diff stats Hide diff stats

  1. +18 0 static/scripts/radio_buttons.js
  2. +6 3 templates/index.html
18 static/scripts/radio_buttons.js
... ... @@ -0,0 +1,18 @@
  1 +jQuery(function($) {
  2 + $('div.btn-group[data-toggle-name=*]').each(function(){
  3 + var group = $(this);
  4 + var form = group.parents('form').eq(0);
  5 + var name = group.attr('data-toggle-name');
  6 + var hidden = $('input[name="' + name + '"]', form);
  7 + $('button', group).each(function(){
  8 + var button = $(this);
  9 + button.live('click', function(){
  10 + hidden.val($(this).val());
  11 + });
  12 + if(button.val() == hidden.val()) {
  13 + button.addClass('active');
  14 + }
  15 + });
  16 + });
  17 +});
  18 +
9 templates/index.html
@@ -4,6 +4,9 @@
4 4 <title>Settle Princeton</title>
5 5 <link href='//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css' rel='stylesheet' />
6 6 <link href='/static/style.css' rel='stylesheet' />
  7 + <script src='/static/jquery.js'></script>
  8 + <script src='/static/scripts/radio_buttons.js'></script>
  9 + <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
7 10 </head>
8 11 <body>
9 12 <h1>Settle Princeton</h1>
@@ -15,9 +18,9 @@
15 18 <input class='span3' name='phone' id='phone' type='text'>
16 19 <label>3 or 4 players?</label>
17 20 <div class="btn-group" data-toggle-name="is_private" data-toggle="buttons-radio" >
18   - <button type="button" value="0" class="btn" data-toggle="button">3</button>
19   - <button type="button" value="1" class="btn" data-toggle="button">4</button>
20   - <button type="button" value="2" class="btn" data-toggle="button">I don't care</button>
  21 + <button type="button" value="3" class="btn" data-toggle="button">3</button>
  22 + <button type="button" value="4" class="btn" data-toggle="button">4</button>
  23 + <button type="button" value="0" class="btn" data-toggle="button">I don't care</button>
21 24 </div>
22 25 <input type="hidden" name="is_private" value="0" />
23 26 <br /><br />

0 comments on commit c4eff26

Please sign in to comment.
Something went wrong with that request. Please try again.