This commit is contained in:
Sanj 2012-07-06 22:02:40 +05:30
parent a1edf3a515
commit 1e06d655ad
3 changed files with 9 additions and 4 deletions

View File

@ -22,7 +22,7 @@ def autocomplete(request):
qset = Person.objects.filter(first_name__icontains=q)
paginator = Paginator(qset, page_limit)
results = paginator.page(page)
items = [{'id': obj.id, 'first_name': obj.first_name, 'last_name': obj.last_name, 'text': obj.first_name} for obj in results.object_list]
items = [{'id': obj.id, 'first_name': obj.first_name, 'last_name': obj.last_name, 'about': obj.about, 'text': obj.first_name + " " + obj.last_name} for obj in results.object_list]
return render_to_json_response({
'items': items,
'has_next': results.has_next()

View File

@ -62,11 +62,13 @@ $(function(){
return {results: data.items, more: more};
}
},
formatResults: function(item) {
formatResult: function(item) {
//console.log(item);
return "<div>" + item.first_name + " " + item.last_name + "</div>";
return "<div>" + item.first_name + " " + item.last_name + "<div style='font-size:12px'><i>" + item.about + "</i></div></div>";
},
formatSelection: function(item) {
//console.log(item);
//return "<div>" + item.first_name + " " + item.last_name + "<div>" + item.about + "</div></div>";
//console.log("foo");
return item.first_name + " " + item.last_name;
//return "<div data-id='" + item.id + "'>" + item.first_name + " " + item.last_name + "</div>";
@ -79,7 +81,8 @@ $(function(){
'id': "x_" + parseInt(Math.random() * 1000),
'text': term,
'first_name': first_name,
'last_name': last_name
'last_name': last_name,
'about': '...'
}
}
});

View File

@ -18,3 +18,5 @@ django-haystack
Markdown
django-crispy-forms
django-floppyforms
django-markitup
twitter