Home > Web Front-end > JS Tutorial > body text

How to use asynchronous search jquery select plug-in

一个新手
Release: 2017-10-20 11:17:39
Original
1518 people have browsed it

Asynchronous real-time search jquery select plug-in

1. First, take a look at the effect.

 

2. The reason for making this plug-in.

1. The amount of data is too large (thousands or tens of thousands) and cannot be loaded all at once.

 2. Existing plug-ins are different and cannot meet functional requirements.

 3. Insufficient aesthetics and controllability.

3. How to use.

 1.html and js


1 <select id="unit"></select>
2 <script type="text/javascript" src="/demo/thirdparty/jquery/jquery-1.8.3.min.js"></script>
3 <script src="/demo/thirdparty/pheker/ajaxselect.js"></script>
Copy after login

 2.Example.


# 使用实例
        var initUrl = "/demo/defineDict.do?method=getEnterpriseDict&unitName="+encodeURIComponent(encodeURIComponent("xx无烟煤矿业集团有限责任公司"));
        var ajaxUrl = "/demo/defineDict.do?method=getEnterpriseDict&unitName=";
        var $select = $("#ajaxselect").ajaxselect({
            initUrl:initUrl,
            ajaxUrl:ajaxUrl,
            defkv:[&#39;id&#39;,&#39;text&#39;],
            selected:0,
        },function(filterData,isInit){
            //filter
            console.log(filterData);
        },function(cbData,isInit){
            //callback
            console.log(cbData);
        });
        $select.on("change", function(){
            console.log(this.value);
        });
Copy after login

 3. Detailed configuration.

var defcfg = {
    initUrl:&#39;&#39;,            //初始化请求地址
    ajaxUrl:&#39;&#39;,            //异步请求地址
    defkv:[],            //返回数据 的key
    delay:200,            //ajax回调 延时
    width:200,            //input 宽度
    height:30,            //input 高度
    selected:-1,        //初始化数据 默认选中项,-1为不选中
    limit:20,            //最大显示条数,0为不限制
    maxheight:250,        //最大显示高度
    hoverbg:&#39;#189FD9&#39;,    //悬浮背景色
    activebg:&#39;#5FB878&#39;,    //选中项背景色
    style:&#39;&#39;            //自定义样式
};
Copy after login

There are also some other APIs, please see the reference link and source code for details.

Four: Statement:

  1. This plug-in is based on the existing plug-in and modified according to your own needs. If you have any minor problems, please modify the source code yourself.

  2. If asynchronous search is not required, other plug-ins such as layui and select2 are also good choices.

  3. In addition, this plug-in depends on jquery

The above is the detailed content of How to use asynchronous search jquery select plug-in. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!