1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| /**
|
| 包依赖:
| /js/jquery-1.11.0.min.js
| /js/cdn/bootstrap3-typeahead.js
| */
| /**
| selector:jquery obj,
|
|
| goodstypeahead('#...',function(gs,obj){
| .....
| });
| */
| var basic=getpath();
| function goodstypeahead (selector,callback) {
| // body...
| var obj=null;
| if(typeof(selector)=='string')
| obj=$(selector);
| else
| obj=selector;
| obj.typeahead({
| source:function (query, process) {
| window.goodsstates = [];//=== window.states=[];
| window.goodsmap = {}; //===window.map={}
| $.ajax({
| url:basic+'/goods/typehead/gdtypehead.htm',
| type:'post',
| data:{query:query},
| dataType:'json',
| ansyc:false,
| success:function(json){
| $.each(json, function (i, item) {
| window.goodsmap[item.name] = item.gs;
| window.goodsstates.push(item.name);
| });
| process(goodsstates);
| }
| });
| },
| updater: function (item) {
| var gs=window.goodsmap[item];
| callback(gs,obj);
| return gs.name;
| }
|
| });
| }
|
|