﻿  /*==========用户自定义方法==========*/
            //设备列表
            var DeviceList;
            //autocomplete选项   这里可以参考官方的  $("#txtTest").autocomplete(DeviceList, options);的方法
            var options = {
                minChars: 1,
                max: 500, 
                dataType:'json',
                matchContains: true, 
                formatItem: function(row, i, max) {
                return row.stockcode+"    "+row.stockname;
                },
                formatMatch: function(row, i, max) {         
                 return row.stockname+row.stockcode;
                },
                formatResult: function(row) { 
                   return row.stockcode;
                
                }
            }; 
            //autocomplete初始化函数
            /*==========加载时执行的语句==========*/
            $(function() { 
        //  $.getJSON(getRootPath()+"/cn/stockcode.htm?aa="+new Date(), function(json){ 
      $.getJSON(getRootPath()+"/Handler/SearchAutoComplete.ashx", function(json){ 
      // $.getJSON("Handler/SearchAutoComplete.ashx", function(json){ 
                DeviceList = json;
                $("#code").autocomplete(DeviceList, options); 
            }); 
            });  
            //获取根目录
 function getRootPath(){ 
var strFullPath=window.document.location.href; 
var strPath=window.document.location.pathname; 
var pos=strFullPath.indexOf(strPath); 
var prePath=strFullPath.substring(0,pos); 
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); 
return(prePath+postPath); 
}  
 
