zoukankan      html  css  js  c++  java
  • easyui combobox实现下拉自动提示补全功能

    <input id="cc" name="nickName" class="easyui-combobox" style="200px">
    var find = function (param, success, error) {
            var q = param.q || "";
            if (q.length <= 0) {
                console.log("q.length <= 0");
                return false;
            }
            $.post("getNickName",{"nickName": q},function (data) {
                debugger
                var items = $.map(data, function(result,index){
                    return {
                        value:index,
                        text:result
                    }; //遍历数组中的值
                });
                /* var items = $.each(data, function(index,value){//第一个是下标,第二个是值
                    return {
                        value:index,
                        text:value
                    }; //遍历数组中的值
                }); */
                success(items);//调用loader的success方法,将items添加到下拉框中
            });
        }
        $('#cc').combobox({
            url : 'getNickName',
            valueField : 'value',
            textField : 'text',
            loader : find,
            mode : 'remote'
        });

    上面代码中find方法是combobox的loader调用的方法

  • 相关阅读:
    22:django 配置详解
    21:序列化django对象
    20:django中的安全问题
    19:django 分页
    HTML 标签(一)
    流程图学习绘制
    HTTP原理
    终端的颜色代码
    Python 进程 线程总结
    Python Select模型
  • 原文地址:https://www.cnblogs.com/zhengyuanyuan/p/9555870.html
Copyright © 2011-2022 走看看