Permalink
Browse files

make autocomplete sort list by shortest length, scrollable.

  • Loading branch information...
1 parent a078b11 commit 8f8670135223860888e7244dd14c25743f2404e0 Jordan Evans committed Aug 11, 2011
Showing with 8 additions and 1 deletion.
  1. +2 −1 railroad/railroad/ajax/autocomplete.py
  2. +6 −0 railroad/static/css/style.css
View
3 railroad/railroad/ajax/autocomplete.py
@@ -28,7 +28,7 @@ def autocomplete(request, context):
"""
query = request.GET.get('term', '')
- limit = int(request.GET.get('limit', 10))
+ limit = int(request.GET.get('limit', 100))
stat, obj = views.parse()
@@ -76,5 +76,6 @@ def autocomplete(request, context):
results = itertools.product(*product_foder)
results = [','.join(result).strip() for result in itertools.islice(results, limit)]
result = [{"value": r} for r in results if r]
+ result.sort(lambda x,y: cmp(len(x['value']), len(y['value'])))
return HttpResponse(json.dumps(result))
View
6 railroad/static/css/style.css
@@ -537,3 +537,9 @@ fieldset {
#pages {
display: none;
}
+
+.ui-autocomplete {
+ max-height: 150px;
+ overflow-y: auto;
+ padding-right: 20px;
+}

0 comments on commit 8f86701

Please sign in to comment.