首页 > Web开发 > 详细

aotocomplete.js

时间:2017-03-09 22:43:55      阅读:208      评论:0      收藏:0      [点我收藏+]

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,    //自动完成激活之前填入的最小字符
                     width: 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,    //自动完成激活之前填入的最小字符
                     width: 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,    //自动完成激活之前填入的最小字符
                     width: 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);
                 });
             }); 
             

 

aotocomplete.js

原文:http://www.cnblogs.com/mrxiaohe/p/6528051.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!