| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <title>jQuery UI - Checkboxes</title> |
| 6 | <link rel="stylesheet" href="../../../themes/base/all.css"> |
| 7 | <script src="../../../external/requirejs/require.js"></script> |
| 8 | <script src="../../../demos/bootstrap.js"> |
| 9 | var checkboxes = $( "form input" ).checkboxradio(); |
| 10 | |
| 11 | $( ".controls input, .controls select" ).on( "change keyup", function() { |
| 12 | var option = $( this ).attr( "name" ), |
| 13 | value = $( this ).val(); |
| 14 | |
| 15 | if ( $( this ).is( "[type=checkbox]" ) ) { |
| 16 | value = $( this ).is( ":checked" ); |
| 17 | } |
| 18 | if ( option != "label" || value !== "" ) { |
| 19 | checkboxes.checkboxradio( "option", option, value ); |
| 20 | } |
| 21 | } ); |
| 22 | $( ".controls > button" ).on( "click", function() { |
| 23 | if ( this.id !== "create" ) { |
| 24 | checkboxes.checkboxradio( this.id ); |
| 25 | } else { |
| 26 | checkboxes.checkboxradio(); |
| 27 | } |
| 28 | } ); |
| 29 | </script> |
| 30 | <style> |
| 31 | #format { margin-top: 2em; } |
| 32 | </style> |
| 33 | </head> |
| 34 | <body> |
| 35 | <h2> |
| 36 | Easy way to toggle through various combinations of options and states to make sure none lead to |
| 37 | a broken appearence. |
| 38 | </h2> |
| 39 | <div class="controls"> |
| 40 | <button id="create">Create</button> |
| 41 | <button id="destroy">Destroy</button> |
| 42 | <button id="enable">Enable</button> |
| 43 | <button id="disable">Disable</button> |
| 44 | <button id="refresh">Refresh</button> |
| 45 | <input type="checkbox" id="icon" name="icon" checked><label for="icon">Icon</label> |
| 46 | <input type="checkbox" id="disabled" name="disabled"><label for="disabled">Disabled</label> |
| 47 | <label for="label">Label<input type="text" id="label" name="label"></label> |
| 48 | </div> |
| 49 | <form> |
| 50 | <input type="checkbox" id="checkbox-1"> |
| 51 | <label for="checkbox-1">Checkbox widget sample</label> |
| 52 | <input type="checkbox" id="checkbox-2"><label for="checkbox-2">Checkbox widget sample</label> |
| 53 | |
| 54 | <label for="radio-1">Radio widget sample <input type="radio" id="radio-1" name="radio" checked></label> |
| 55 | <input type="radio" id="radio-2" name="radio"><label for="radio-2"><span>boom</span>Radio widget sample 2</label> |
| 56 | <button type="reset">Reset</button> |
| 57 | </form> |
| 58 | </body> |
| 59 | </html> |