Closed sajadghawami closed 3 years ago
Why is the local option in the Bloodhound set to the Bloodhound instance?
local: typeahead_fach
thats how the example for bloodhound looked like. And it works too:
// constructs the suggestion engine
var states = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// `states` is an array of state names defined in "The Basics"
local: states
});
$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'states',
source: states
});
// `states` is an array of state names defined in "The Basics"
The states
was created before as an array from the previous example. So it was something like this:
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
];
// constructs the suggestion engine
var states = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// `states` is an array of state names defined in "The Basics"
local: states
});
$('#bloodhound .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'states',
source: states
});
yeah! didnt want to copy the whole code, but thats how i use it.
as you can see, it uses the local option in the Bloodhound as the Bloodhound instance
No. It uses the states array as the local option.
-----Original Message----- From: "leakingminds" notifications@github.com Sent: 8/13/2015 5:05 PM To: "twitter/typeahead.js" typeahead.js@noreply.github.com Cc: "Samuel" samuelimolo4real@gmail.com Subject: Re: [typeahead.js] Bloodhound, minLength and default suggestionsdoesnt work (#1346)
yeah! didnt want to copy the whole code, but thats how i use it. as you can see, it uses the local option in the Bloodhound as the Bloodhound instance — Reply to this email directly or view it on GitHub.
But isnt that what you meant in your comment earlier?
Nonetheless, i use it like the example.
"tyepeahead_fach" is my array and bloodhound works without a problem.
Got the same error when using remote. I think this comment describes why: http://stackoverflow.com/a/30330790/219900
got any solution for the above problem?
I got the same problem. To work I added the same line of the file bootstrap-typeahead.js in my function. And works!! I think is not the better way to do, what do you all think?
this.element.find('input[type=search]').typeahead({
autoSelect: false,
items: 20,
delay: 300,
minLength: 3,
highlighter: function (item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '<strong>' + match + '</strong>'
})
}
});
I tried even with the highlighter, default suggestions are not coming up with click. Can someone please help me with this - http://jsfiddle.net/RavindraBajpai/gc4d0Lwn/1/
To make it work figured out a hacky way with - $('#my-datasets .typeahead').on( 'click', function() { $(this).typeahead( 'val', 'a' ); $(this).typeahead( 'open'); });
But it doesn't sound a nice solution. Please suggest
I had to upgrade from version 0.11.1
to the latest version here to resolve the issue:
https://github.com/corejavascript/typeahead.js/releases
minLength still does not work reliably on 0.11.1
minLength still does not work reliably on 0.11.1
@jeffz2012 minLength is working fine. Here my code -
this.typeahead({
minLength: 3
},
{ name: 'search',
displayKey: 'id',
source: searchedVariants,
templates: {
empty: [
'<div class="empty-message">',
'No result found',
'</div>'
].join('\n'),
pending: function (query) {
return '<div>Loading...</div>';
},
suggestion: function(variant){
window.variantTemplate = Handlebars.compile($("#variants_template").text());
return formatVariantResult(variant)
}
}
});
Hello there,
i tried everything, checked every issue related to this, but i dont seem to get it to work.
Thats my code:
it shows me the usual stuff in my array "typeahead_fach" but deosnt show any default suggestions.
Whats happening?