Reputation: 8347
I am using the Twitter Typeahead.js library, together with TagManager in order to search for people from my LDAP directory and put the selected people in a tag list.
I have a Django function that returns a list of matching people in JSON format.
When I start typing in the input text field, I need typeahead to call the remote link as follows:
http:\\mydomain.com\people_search?term=JohnSmith
My Django function then extracts JohnSmith (form the link format, it can be seen that it is via GET method) adn returns the result in JSON format. The result should be used to populate the dropdown list in the input field.
I hope my problem was clear enough. If not, please let me know so that I can clarify.
How do I do the above? TagManager and TypeAhead seem to be pretty cool, but if I cannot autocomplete via a simple method, that would be uncool.
Edit: My typeahead snippet:
jQuery("input#people-tm").typeahead({
name: 'countries',
limit: 15,
remote: "{% url 'people_search' %}"
}).on('typeahead:selected', function (e, d) {
tagApi.tagsManager("pushTag", d.value);
});
Thanks a lot.
Upvotes: 0
Views: 408
Reputation: 599570
Looking at the docs, you just need to insert the %QUERY
placeholder in your remote URL:
remote: "{% url 'people_search' %}?term=%QUERY"
Upvotes: 0