autocomplete插件为我们带来了很多便利,在
http://view.jquery.com/trunk/plugins/autocomplete/demo/
中有一些源代码的演示,想仔细研究下它的代码意图。(看图分析代码)
(1)Single City(local),表示本地数据,它后台的处理怎么样的呢?
$("#singleCity").focus().autocomplete(cities);
而此时的cities,已经存在了。存在一个js文件中,
var cities = [
"Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron",
"Albany", "Alexandria", "Alger", "Alledonia", "Alliance", "Alpha", "Alvada",
"Alvordton", "Amanda", "Amelia", "Amesville", "Amherst", "Amlin", "Amsden",
"Amsterdam", "Andover", "Anna", "Ansonia", "Antwerp", "Apple Creek", "Arcadia",
"Arcanum", "Archbold", "Arlington", "Ashland", "Ashley", "Ashtabula", "Ashville"];
内部已经已经实现了autocomplete()方法了。