5

Does typeahead feature support remote data source in version 2.0.3 of twitter-bootstrap?

The link to typehead functionality http://twitter.github.com/bootstrap/javascript.html#typeahead

Nambi
  • 2,688
  • 8
  • 28
  • 37
  • "source : array". I think you have to build the array yourself. (BTW JQueryUI Autocomplete (http://jqueryui.com/demos/autocomplete/remote.html) allows JSON as source file) – maxdec May 21 '12 at 06:25
  • See this post http://stackoverflow.com/questions/9232748/twitter-bootstrap-typeahead-ajax-example – Dan Power Aug 11 '12 at 11:58
  • go with autocomplete jquery-ui, it's more more simple to use. – Mauro Jul 17 '13 at 12:36

1 Answers1

4

Did you try:

$('.typeahead').typeahead({
    source: function (query, typeahead) {
        return $.post('/typeahead', { query: query }, function (data) {
            return typeahead.process(data);
        });
    }
});
founddrama
  • 2,391
  • 1
  • 22
  • 31
HaNdTriX
  • 28,732
  • 11
  • 78
  • 85
  • 3
    This worked for me, but only if the arguments for the function were reversed in order: function (query, callback) instead of (callback, query). – Eric R. Rath Oct 16 '12 at 17:02