I am using typeahead on my user database and everything seems to work fine. However, the search I am performing on is the last name of a member.
What I am trying to do is once a user is clicked on, instead of using the last name they entered into the field, I want to have it add the users ID to the field instead.
Is there a way to go about doing this?
$('input.query').typeahead({
name: 'query',
value: 'lastName',
remote: 'jsonUser.php?query=%QUERY',
minLength: 3,
template: ["<div class='typeahead_wrapper'>",
"<img class='typeahead_photo' src='http://localhost/iwebimage.axd?qid={{qid}}'/>",
"<div class='typeahead_labels'>",
"<div class='typeahead_primary'>{{firstName}} {{lastName}} <small>({{ntid}})</small></div>",
"<div class='typeahead_secondary'>{{department}}</div>",
"</div>",
"</div>", ].join(''),
engine: Hogan,
limit: 8,
valueKey: 'lastName'
});
UPDATE:
The JSON response contains the ID of the user, just not sure how to have the plugin use another value as the final value rather then what you are searching.