iOS-style sticky headers with jQuery
iOSList is a jQuery plugin that creates iOS-style sticky headers similar to those seen in the Music and Contacts apps on Apple devices. It is tested to work in the following browsers:
Download the production version.
In your web page:
<!-- in the head tag -->
<link rel="stylesheet" href="https://github.com/brianhadaway/iOSList/blob/master/css/jquery.ioslist.css" />
<!-- somewhere in the body tag -->
<div id="list1">
<div class="ioslist-group-container">
<div class="ioslist-group-header">A</div>
<ul>
<li>Afghanistan</li>
<li>Akrotiri</li>
<li>Albania</li>
<li>Algeria</li>
<li>American Samoa</li>
</ul>
</div>
<div class="ioslist-group-container">
<div class="ioslist-group-header">B</div>
<ul>
<li>Bahamas, The</li>
<li>Bahrain</li>
<li>Bangladesh</li>
<li>Barbados</li>
<li>Bassas da India</li>
</ul>
</div>
<div class="ioslist-group-container">
<div class="ioslist-group-header">C</div>
<ul>
<li>Cambodia</li>
<li>Cameroon</li>
<li>Canada</li>
<li>Cape Verde</li>
<li>Cayman Islands</li>
</ul>
</div>
</div>
<!-- near closing body tag -->
<script src="https://github.com/brianhadaway/iOSList/raw/master/js/jquery.min.js"></script>
<script src="https://github.com/brianhadaway/iOSList/raw/master/js/jquery.ioslist.js"></script>
<script>
$(function(){
$("#list1").ioslist();
});
</script>
$('.my-list').ioslist().on('ajax:success', function() {
// after adding new elements to the DOM
$(this).data('instance').refreshElements();
});
@TODO
In lieu of a formal styleguide, take care to maintain the existing coding style.
Also, please don't edit JS files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!
Copyright (c) 2014 Brian Hadaway Licensed under the MIT license.