Answer the question
In order to leave comments, you need to log in
Why is typeahead not working?
I use this plugin: https://github.com/bassjobsen/Bootstrap-3-Typeahead
This is how tooltips are:
$('#cityName').typeahead(
{
source: [
{id: "0", name: "Москва"},
{id: "1", name: "Владивосток"}
],
autoSelect: true
});
function getList(query) {
return [
{id: "0", name: "Киев"},
{id: "1", name: "Чернигов"}
]
}
$('#cityName').typeahead(
{
source: getList,
autoSelect: true
});
Answer the question
In order to leave comments, you need to log in
You need to run callback function
Example:
$('#cityName').typeahead(
{
source: function (query, handler) {
var data = [
{id: "0", name: "Киев"},
{id: "1", name: "Чернигов"}
]
handler(data);
},
autoSelect: true
}
);
Why does the getList function need a query parameter that is not used?
source: getList means to pass a reference to a function, not to call a function (to get a result)
at all, the approach is kind of strange, but what you expect will probably be if you write source: getList()
And yes, do not use alerts .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question