comparison gpp/core/widgets.py @ 326:5453aedf95fd

Adjusting the auto-complete to only require 1 character minimum before querying, and return 15 results instead of 10.
author Brian Neal <bgneal@gmail.com>
date Sun, 20 Feb 2011 22:12:06 +0000
parents be3fff614b93
children
comparison
equal deleted inserted replaced
325:d8b634e67043 326:5453aedf95fd
18 $(function() { 18 $(function() {
19 var cache = {}; 19 var cache = {};
20 var cacheSize = 0; 20 var cacheSize = 0;
21 $("#id_%s").autocomplete({ 21 $("#id_%s").autocomplete({
22 delay: 400, 22 delay: 400,
23 minLength: 2, 23 minLength: 1,
24 source: function(request, response) { 24 source: function(request, response) {
25 if (cache[request.term]) { 25 if (cache[request.term]) {
26 response(cache[request.term]); 26 response(cache[request.term]);
27 return; 27 return;
28 } 28 }
29 $.ajax({ 29 $.ajax({
30 url: "%s", 30 url: "%s",
31 type: "GET", 31 type: "GET",
32 data: { 32 data: {
33 q: request.term, 33 q: request.term,
34 limit: 10 34 limit: 15
35 }, 35 },
36 dataType: "json", 36 dataType: "json",
37 success: function(data, textStatus) { 37 success: function(data, textStatus) {
38 if (cacheSize >= 16) { 38 if (cacheSize >= 32) {
39 cache = {}; 39 cache = {};
40 cacheSize = 0; 40 cacheSize = 0;
41 } 41 }
42 cache[request.term] = data; 42 cache[request.term] = data;
43 ++cacheSize; 43 ++cacheSize;