zoukankan      html  css  js  c++  java
  • jquery插件:aotocomplete

    aotocomplete.js

    http://blog.csdn.net/smeyou/article/details/7980273?_t_t_t=0.3565731019350138

    $(function() {
                     //alert(goodObj)
                     //alert(emails)
                     $('#typeNum').autocomplete(goodObj, {
                         max: 1000,    //列表里的条目数
                         minChars: 0,    //自动完成激活之前填入的最小字符
                          400,     //提示的宽度,溢出隐藏
                         scrollHeight: 200,   //提示的高度,溢出显示滚动条
                         matchContains: true,    //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
                         autoFill: false,    //自动填充
                         mustMatch:true,
                         formatItem: function(row, i, max) {
                             return i + '/' + max + ':"' + row.typeNum + '"[' + row.serialNum + ']'+"库存:"+'"[' + row.repertory + ']';
                         },
                         formatMatch: function(row, i, max) {
                             return row.typeNum +"/"+ row.serialNum;
                         },
                         formatResult: function(row) {
                             return row.typeNum +"/"+ row.serialNum;
                         }
                     }).result(function(event, row, formatted) {
                          if(row) {
                              
                                 //alert(row.serialNum);
                                 //$(this).val(row.typeNum+" "+row.serialNum);
                                 //alert(row.id)
                          }
                              //tr.find("input[name=id]").val(data[0]);  //不加此判断会报错:data[0]为null
                     });
                 });
     var emails = [
                  { name: "Peter Pan", to: "gggsa@pan.de",id:1 },
                 { name: "Molly", to: "molly@yahoo.com",id:"2" },
                 { name: "Forneria Marconi", to: "live@japan.jp",id:3 },
                 { name: "Master <em>Sync</em>", to: "205bw@samsung.com",id:4 },
                 { name: "Dr. <strong>Tech</strong> de Log", to: "g15@logitech.com",id:5 },
                 { name: "Don Corleone", to: "don@vegas.com",id:6 },
                 { name: "Mc Chick", to: "info@donalds.org",id:"7" },
                 { name: "Donnie Darko", to: "dd@timeshift.info",id:8 },
                 { name: "Quake The Net", to: "webmaster@quakenet.org",id:9 },
                 { name: "Dr. Write", to: "write@writable.com",id:10 },
                 { name: "GG Bond", to: "Bond@qq.com",id:11 },
                 { name: "Zhuzhu Xia", to: "zhuzhu@qq.com",id:12 }
             ];
     
                 $(function() {
                     $('#keyword').autocomplete(emails, {
                         max: 10,    //列表里的条目数
                         minChars: 0,    //自动完成激活之前填入的最小字符
                          400,     //提示的宽度,溢出隐藏
                         scrollHeight: 300,   //提示的高度,溢出显示滚动条
                         matchContains: true,    //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
                         autoFill: false,    //自动填充
                         formatItem: function(row, i, max) {
                             return i + '/' + max + ':"' + row.name + '"[' + row.to + ']'+'"[' + row.id + ']';
                         },
                         formatMatch: function(row, i, max) {
                             return row.name + row.to;
                         },
                         formatResult: function(row) {
                             return row.to;
                         }
                     }).result(function(event, row, formatted) {
                         alert(row.to);
                     });
                 }); 
                 
     var emails = [
                  { name: "Peter Pan", to: "gggsa@pan.de",id:1 },
                 { name: "Molly", to: "molly@yahoo.com",id:"2" },
                 { name: "Forneria Marconi", to: "live@japan.jp",id:3 },
                 { name: "Master <em>Sync</em>", to: "205bw@samsung.com",id:4 },
                 { name: "Dr. <strong>Tech</strong> de Log", to: "g15@logitech.com",id:5 },
                 { name: "Don Corleone", to: "don@vegas.com",id:6 },
                 { name: "Mc Chick", to: "info@donalds.org",id:"7" },
                 { name: "Donnie Darko", to: "dd@timeshift.info",id:8 },
                 { name: "Quake The Net", to: "webmaster@quakenet.org",id:9 },
                 { name: "Dr. Write", to: "write@writable.com",id:10 },
                 { name: "GG Bond", to: "Bond@qq.com",id:11 },
                 { name: "Zhuzhu Xia", to: "zhuzhu@qq.com",id:12 }
             ];
     
                 $(function() {
                     $('#keyword').autocomplete(emails, {
                         max: 10,    //列表里的条目数
                         minChars: 0,    //自动完成激活之前填入的最小字符
                          400,     //提示的宽度,溢出隐藏
                         scrollHeight: 300,   //提示的高度,溢出显示滚动条
                         matchContains: true,    //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
                         autoFill: false,    //自动填充
                         formatItem: function(row, i, max) {
                             return i + '/' + max + ':"' + row.name + '"[' + row.to + ']'+'"[' + row.id + ']';
                         },
                         formatMatch: function(row, i, max) {
                             return row.name + row.to;
                         },
                         formatResult: function(row) {
                             return row.to;
                         }
                     }).result(function(event, row, formatted) {
                         alert(row.to);
                     });
                 }); 
                 
  • 相关阅读:
    【模板时间】◆模板·III◆ 单调子序列
    【学时总结】◆学时·VII◆ 高维DP
    【例题收藏】◇例题·IV◇ Wooden Sticks
    【赛时总结】◇赛时·VI◇ Atcoder ABC-104
    【例题收藏】◇例题·III◇ 木と整数 / Integers on a Tree
    【学时总结】◆学时·VI◆ SPLAY伸展树
    【模板时间】◆模板·II◆ 树链剖分
    【赛时总结】◇赛时·V◇ Codeforces Round #486 Div3
    【例题收藏】◇例题·II◇ Berland and the Shortest Paths
    【例题收藏】◇例题·I◇ Snuke's Subway Trip
  • 原文地址:https://www.cnblogs.com/mrxiaohe/p/6528051.html
Copyright © 2011-2022 走看看