Making the server return an unordered list for Autocompleter
I didn't realize that it was much easier to work with the Ajax.Autocompleter if the server returned a <ul> element rather than JSON. To make dealing with this much easier, I encourage you to edit autocomplete/views.py and replace the complete function with this:
def complete(request):
word = request['word']
completions = word_list.get_words_with_prefix(word)
res = '<ul>'
for completion in completions:
res += '<li>' + completion + '</li>'
res += '</ul>'
return HttpResponse(res);
def complete(request):
word = request['word']
completions = word_list.get_words_with_prefix(word)
res = '<ul>'
for completion in completions:
res += '<li>' + completion + '</li>'
res += '</ul>'
return HttpResponse(res);

0 Comments:
Post a Comment
<< Home