Created by: elmariachi111
This commit allows Typeahead users to query a remote API and keep their results. After a user selects an item from the list the updater has access to the original response object to trigger another action (provide your own updater function). Makes use of the data-attribute pull request as suggested here: martinnormark: https://github.com/twitter/bootstrap/pull/6015
added a textproperty function on Typeahead.prototype that pulls the correct property from the result. Puts more logic to Typeahead base, leaves less work to the client (as supposed in #6015).
Similar to Pull Request https://github.com/twitter/bootstrap/pull/6056 but needs only one additional parameter function.
Tested against local PhantomJS test (make test)
Usage example:
$element.typeahead( {
textproperty: function(item) {
return item.formatted_address; //choose the text field of the result object
}, updater: function(item) {
console.dir(item); //do something with the result object / callback / move map marker etc.
return this.text(item); //aka super(item)
}
}