a jQuery plugin to collapse and search nested lists (2 levels)
Markup example:
<ul id="my-list">
<li class="header">A</li>
<ul>
<li>Australia</li>
<li>Austria</li>
</ul>
<li class="header">B</li>
<ul>
<li>Bahamas, The</li>
<li>Bahrain</li>
</ul>
</ul>Javascript code:
The first argument is a selector to get the headers of each sub-list. The second are the options.
$('#my-list').collapsibleList('.header');$('#my-list').collapsibleList('.header', {search: false});The search is case insensitive and does not have to start from the beginning of the word (e.g. 'merica' will match 'America').
If the filtered nested sub-lists result in having no items after a search, the header is hidden.
ESC will clear the search field and remove the focus (blur). If some sub-lists were collapsed, the state is stored before the search and restored when the search field is empty or if you press ESC.
-
search: one oftrue,falseor ajQueryinstanceWhen
true, creates and add a search field at the top of the list. Whenfalse, no search field is added. When it's ajQueryinstance, this field will be used for the search and key handlers will be set on it. -
animate:trueorfalseEnable or disable animation.