Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
- <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
- <script>
- var contacts = [
- {"fname":"John", "lname":"Smith","phone":"(239)555-5555"},
- {"fname":"Jim", "lname":"Parker","phone":"(239)555-3333"},
- {"fname":"Tom", "lname":"Rock","phone":"(239)555-4322"}
- ];
- contacts = sortByKey(contacts, 'lname');
- function sortByKey(array, key) {
- return array.sort(function(a, b) {
- var x = a[key]; var y = b[key];
- return ((x < y) ? -1 : ((x > y) ? 1 : 0));
- });
- }
- $(document).ready(function(){
- contacts.forEach(function(contact){
- $("#list").append('<li>'+
- '<a href="#" class="ui-btn">'+
- // '<img src="res/iaff1.png" alt="FireFighter">'+
- '<h3>'+contact.lname+', '+contact.fname+'</h3>'+
- '<p>'+contact.phone+'</p>'+
- '</a></li>');
- $("#list").listview("refresh");
- });
- });
- </script>
- </head>
- <body>
- <div data-role="page" id="pageone">
- <div data-role="main" class="ui-content">
- <h2>My Phonebook</h2>
- <form class="ui-filterable">
- <input id="myFilter" data-type="search">
- </form>
- <ul id="list" data-role="listview" data-filter="true" data-input="#myFilter" data-autodividers="true" data-inset="true">
- </ul>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement