2012-05-21 11 views
5

La caratteristica typeahead supporta l'origine dati remota nella versione 2.0.3 di twitter-bootstrap?Twitter typsteadstrap typeahead supporta l'origine dati remota?

Il link alla testina di stampa funzionalità http://twitter.github.com/bootstrap/javascript.html#typeahead

+0

"fonte: array". Penso che tu debba costruire l'array da solo. (BTW JQueryUI Autocomplete (http://jqueryui.com/demos/autocomplete/remote.html) consente JSON come file sorgente) – maxdec

+0

Vedere questo post http://stackoverflow.com/questions/9232748/twitter-bootstrap-typeahead-ajax -esempio –

+0

vai con completamento automatico jquery-ui, è più semplice da usare. – Mauro

risposta

4

Hai provato:

$('.typeahead').typeahead({ 
    source: function (query, typeahead) { 
     return $.post('/typeahead', { query: query }, function (data) { 
      return typeahead.process(data); 
     }); 
    } 
}); 
+3

Questo ha funzionato per me, ma solo se gli argomenti per la funzione sono stati invertiti nell'ordine: function (query, callback) anziché (callback, query). –

Problemi correlati