jQuery Searchable Plugin
========================
*Latest version: v1.1.0* (View the [changelog](#changelog))
Tiny, fast jQuery plugin to search through elements as you type. This plugin is created and maintained by **Stidges** ( [Twitter](http://twitter.com/stidges) | [Github](http://github.com/stidges) ).
## Features
- **Lightweight**. This plugin is only ~1kB minified and gzipped!
- **Fast**. This plugin is optimized for fast, lagless searching even through large element sets.
- **Multiple search types**. This plugin provides three different search types out-of-the-box! Fuzzy matching, strict (case sensitive) matching and default (case insensitive) matching.
- **Automatic row striping**. When searching through a table, rows get hidden when they don't match. When using a CSS framework like [Bootstrap](http://getbootstrap.com) this would mess up your table striping. This plugin makes allows you to define the CSS to be applied to odd and even rows, and updates them while searching.
- **Custom show/hide**. You can define custom functions for showing and hiding the elements while searching.
- **Search anything**. This plugin isn't restricted to use on tables, any set of elements that has 'rows' with 'columns' inside them can be used.
## Demo
[Click here](http://bootsnipp.com/snippets/93XX) to view a demo of this plugin in action (Hosted on [Bootsnipp](http://bootsnipp.com))
## Getting started
### Basic usage
After downloading this plugin, include it in your HTML file after loading jQuery:
```html
<script src="jquery.js"></script>
<script src="jquery.searchable.js"></script>
```
**Note**: If you want to support older browsers like <IE9, you can use the `jquery.searchable-ie.js` instead of `jquery.searchable.js`. This version includes a polyfill for the `Array.prototype.reduce` function and is therefore slightly larger (a couple hundred bytes).
After that, you can simply initialize the plugin on the desired element. This example uses a table with an id of 'table'. By default, the plugin uses an input with an id of 'search' (read about how to change this in the Configuration section below):
```js
$( '#table' ).searchable();
```
### Configuration
This plugin provides the following configuration options:
| Option | Default value | Description |
| :------ | :------------- | :----------- |
| selector | `'tbody tr'` | Defines the main jQuery selector within the element on which the plugin is initialized. This selects the container elements to show or hide, such as `tr`s within a table, or a `div.your-special-class` within the searchable element.|
| childSelector | `'td'` | Defines the child selector within the 'selector' defined above. This selects the searchable elements within the 'selector' element, such as `td` or `.searchable`.|
| searchField | `'#search'` | The input element that is used for the search input filter |
| striped | `false` | Defines whether the element is striped and should be re-striped upon searching (either `true` or `false`) |
| oddRow | `{ }` | Defines the CSS object to apply to the odd rows (when `striped` is set to `true`). |
| evenRow | `{ }` | Defines the CSS object to apply to the even rows (when `striped` is set to `true`). |
| hide | `function` | Allows you to define a custom hiding function. This function accepts one parameter, which is the element (row) being hidden. By default it will use `elem.hide()` to hide the row. |
| show | `function` | Allows you to define a custom show function. This function accepts one parameters, which is the element (row) being hidden. By default it will use `elem.show()` to show the row. |
| searchType | `'default'` | Defines the matcher to be used when searching. Allowed values are `'fuzzy'`, `'strict'` and `'default'`. |
| onSearchActive | `false` | Allows you to define a function to be called when the search is active. This function will be called whenever the user is typing into the search input and the search input is not empty. The searchable element and the search term will be passed to the function. |
| onSearchEmpty | `false` | Allows you to define a function to be called when the search input is empty. This function will be called once when the search input is empty or cleared. The searchable element will be passed to the function. |
| onSearchFocus | `false` | Allows you to define a function to be called when the search input is focussed. The `this` context of this function will be the search input element. |
| onSearchBlur | `false` | Allows you to define a function to be called when the search input is blurred. The `this` context of this function will be the search input element. |
| clearOnLoad | `false` | Determines whether the search input should be cleared on page load (either `true` or `false`). |
### Example usage
This example uses the configurations shown above to customize the plugin:
```js
$( '#element' ).searchable({
selector : '.row',
childSelector : '.column',
searchField : '#mySearchInput',
striped : true,
oddRow : { 'background-color': '#f5f5f5' },
evenRow : { 'background-color': '#fff' },
hide : function( elem ) {
elem.fadeOut(50);
},
show : function( elem ) {
elem.fadeIn(50);
},
searchType : 'fuzzy',
onSearchActive : function( elem, term ) {
elem.show();
},
onSearchEmpty: function( elem ) {
elem.hide();
},
onSearchFocus: function() {
$( '#feedback' ).show().text( 'Type to search.' );
},
onSearchBlur: function() {
$( '#feedback' ).hide();
},
clearOnLoad: true
});
```
## Changelog
**Version 1.0.0:**
- Initial release.
**Version 1.1.0:**
- Added some events that allow you to call custom functions during the search lifecycle: onSearchActive, onSearchEmpty, onSearchFocus, onSearchBlur (view the [configuration](#configuration) for more information).
- Added the `clearOnLoad` setting which allows you to clear the search input on page load / refresh.
## Contributing & Issues
Please feel free to submit any issues or pull requests, they are more then welcome. When submitting an issue, please specify the version number and describe the issue in detail so that it can be solved as soon as possible!
## License
Copyright (c) 2014 - Stidges - Licensed under [the MIT license](LICENSE).
没有合适的资源?快使用搜索试试~ 我知道了~
这是 jQuery 的 DataTables 插件的一个附加组件,它根据表colu中的数据 创建过滤小部件 JavaScript
共13个文件
js:6个
json:2个
gitattributes:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2022-07-12
23:00:54
上传
评论
收藏 13KB ZIP 举报
温馨提示
这是 jQuery 的 DataTables 插件的附加组件,它根据表列中的数据创建过滤小部件。 这是 jQuery 的 DataTables 插件的附加组件,它根据表列中的数据创建过滤小部件。 小部件在布局元素中分组,独立于源列。 可以对一列进行多项选择,并且其他小部件会调整以反映结果。 可以使用分隔符(如逗号)从单个表格单元格中解析多个值。 选择可以与源下拉列表进行分组,或者全部放在一个公共布局元素中。 可以单独删除选择。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
jquery-searchable-master.zip (13个子文件)
jquery-searchable
package.json 735B
jquery.searchable-ie.js 7KB
LICENSE 1KB
dist
jquery.searchable-1.0.0.min.js 2KB
jquery.searchable-1.1.0.min.js 3KB
jquery.searchable-ie-1.1.0.min.js 3KB
Gruntfile.js 2KB
.gitignore 23B
README.md 6KB
jquery.searchable.js 6KB
.jshintrc 318B
bower.json 626B
.gitattributes 24B
共 13 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Esercizi di informatica!执行计划,metti alla prova!.zip
- Eloquent JavaScript 翻译 - 2ª edição .zip
- Eclipse Paho Java MQTT 客户端库 Paho 是一个 Eclipse IoT 项目 .zip
- disconf 的 Java 应用程序.zip
- cloud.google.com 上使用的 Java 和 Kotlin 代码示例.zip
- 未命名3(3).cpp
- fluent 流体动力学CFD
- Azure Pipelines 文档引用的示例 Java 应用程序.zip
- Apereo Java CAS 客户端.zip
- RAW文件的打开方法与专业处理工具推荐
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功