Listbox.js ========== :Author: `Igor Kalnitsky `_ :License: `BSD 3-clause`_ :Version: 0.3.0-dev :Tests: |travis| **Listbox.js** is a simple jQuery plugin that provides a more powerful alternative to the standard ```` tag. The main problem of ```` tag and creates an alternative to the last one based on ```` tags. It opens up great possibilities for customization. In addition, this component provides the search bar which would be useful in lists with a lot of items. This component was born special for XSnippet_ project. **NOTE:** This is my first JavaScript code. So don't judge strictly. Usage ----- Link the component and a stylesheet from your page. .. code:: html Create Listbox object. .. code:: html Item #1 Item #2 Item #3 Item #4 Customization ------------- Listbox.js uses following ``CSS`` classes. .. code:: css .lbjs {} /* : component container */ .lbjs-list {} /* : container for list items */ .lbjs-item {} /* : list item */ .lbjs-item:not([disabled]) {} /* : enabled list item */ .lbjs-item[disabled] {} /* : disabled list item */ .lbjs-item[selected] {} /* : selected list item */ .lbjs-searchbar {} /* : search query input */ FAQ --- - **How to bind event handler to the `click` list item event?** Because of Listbox.js dynamically changes DOM you should use jQuery's ``live()`` method: .. code:: js $('.myListboxClass .lbjs-item').live('click', function() { alert($(this).html()); }); - **How to make disabled item?** The process is similar to making disabled items in the ````-tag. All you need is to set the ``disabled`` attribute. .. code:: js $('.myOwnClass .lbjs-item').each(function () { var value = $(this).html(); if (['PHP', 'JavaScript'].indexOf(value) != -1) $(this).attr('disabled', ''); }); .. _BSD 3-clause: http://raw.github.com/ikalnitsky/listbox.js/master/LICENSE .. _XSnippet: http://xsnippet.org/ .. |travis| image:: https://travis-ci.org/ikalnitsky/listbox.js.png?branch=master 部分文件列表(点击文件名可查看文件内容) 本源码包内暂不包含可直接显示的源代码文件,请下载源码包。