Created
December 22, 2012 14:43
-
-
Save axooh/4359141 to your computer and use it in GitHub Desktop.
Refreshing jQuery Mobile listviews, buttons, select dropdowns, and input fields
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
| // Textarea fields | |
| $('body').prepend('<textarea id="myTextArea"></textarea>'); | |
| $('#myTextArea').textinput(); | |
| // Text input fields | |
| $('body').prepend('<input type="text" id="myTextField" />'); | |
| $('#myTextField').textinput(); | |
| // Buttons | |
| $('body').append('<a href="" data-theme="e" id="myNewButton">testing</a>'); | |
| $('#myNewButton').button(); | |
| // Combobox or select dropdowns | |
| <label for="sCountry">Country:</label> | |
| <select name="sCountry" id="sCountry"> | |
| <option value="">Where You Live:</option> | |
| <option value="ad">Andorra</option> | |
| <option value="ae">United Arab Emirates</option> | |
| </select> | |
| var myselect = $("#sCountry"); | |
| myselect[0].selectedIndex = 3; | |
| myselect.selectmenu('refresh'); | |
| // Listviews | |
| <ul id="myList" data-role="listview" data-inset="true"> | |
| <li>Acura</li> | |
| <li>Audi</li> | |
| <li>BMW</li> | |
| </ul> | |
| $('#mylist').listview('refresh'); | |
| // Slide control | |
| <div data-role="fieldcontain"> | |
| <label for="slider-2">Input slider:</label> | |
| <input type="range" id="slider-2" value="25" min="0" max="100" /> | |
| </div> | |
| $('#slider-2').val(80).slider('refresh'); | |
| // Toggle Switch | |
| <div data-role="fieldcontain"> | |
| <label for="toggle">Flip switch:</label> | |
| <select name="toggle" id="toggle" data-role="slider"> | |
| <option value="off">Off</option> | |
| <option value="on">On</option> | |
| </select> | |
| </div> | |
| var myswitch = $("#toggle"); | |
| myswitch[0].selectedIndex = 1; | |
| myswitch .slider("refresh"); | |
| // Radio buttons | |
| <div data-role="fieldcontain"> | |
| <fieldset data-role="controlgroup" data-type="horizontal"> | |
| <legend>Layout view:</legend> | |
| <input type="radio" name="radio-view" value="list" /> | |
| <label for="radio-view-a">List</label> | |
| <input type="radio" name="radio-view" value="grid" /> | |
| <label for="radio-view-b">Grid</label> | |
| <input type="radio" name="radio-view" value="gallery" /> | |
| <label for="radio-view-c">Gallery</label> | |
| </fieldset> | |
| </div> | |
| $("input[value=grid]").attr('checked',true).checkboxradio('refresh'); | |
| // Checkboxes | |
| <div data-role="fieldcontain"> | |
| <fieldset data-role="controlgroup"> | |
| <legend>Agree to the terms:</legend> | |
| <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" /> | |
| <label for="checkbox-1">I agree</label> | |
| </fieldset> | |
| </div> | |
| $('#checkbox-1').attr('checked',true).checkboxradio('refresh'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment