aotocomplete.js

Posted Mr.He多多指教

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了aotocomplete.js相关的知识,希望对你有一定的参考价值。

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: "[email protected]",id:1 },
             { name: "Molly", to: "[email protected]",id:"2" },
             { name: "Forneria Marconi", to: "[email protected]",id:3 },
             { name: "Master <em>Sync</em>", to: "[email protected]",id:4 },
             { name: "Dr. <strong>Tech</strong> de Log", to: "[email protected]",id:5 },
             { name: "Don Corleone", to: "[email protected]",id:6 },
             { name: "Mc Chick", to: "[email protected]",id:"7" },
             { name: "Donnie Darko", to: "[email protected]",id:8 },
             { name: "Quake The Net", to: "[email protected]",id:9 },
             { name: "Dr. Write", to: "[email protected]",id:10 },
             { name: "GG Bond", to: "[email protected]",id:11 },
             { name: "Zhuzhu Xia", to: "[email protected]",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: "[email protected]",id:1 },
             { name: "Molly", to: "[email protected]",id:"2" },
             { name: "Forneria Marconi", to: "[email protected]",id:3 },
             { name: "Master <em>Sync</em>", to: "[email protected]",id:4 },
             { name: "Dr. <strong>Tech</strong> de Log", to: "[email protected]",id:5 },
             { name: "Don Corleone", to: "[email protected]",id:6 },
             { name: "Mc Chick", to: "[email protected]",id:"7" },
             { name: "Donnie Darko", to: "[email protected]",id:8 },
             { name: "Quake The Net", to: "[email protected]",id:9 },
             { name: "Dr. Write", to: "[email protected]",id:10 },
             { name: "GG Bond", to: "[email protected]",id:11 },
             { name: "Zhuzhu Xia", to: "[email protected]",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的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数