corejavascript / typeahead.js Goto Github PK
View Code? Open in Web Editor NEWtypeahead.js is a fast and fully-featured autocomplete library
Home Page: https://typeahead.js.org/
License: MIT License
typeahead.js is a fast and fully-featured autocomplete library
Home Page: https://typeahead.js.org/
License: MIT License
Hello,
I know yours is a forked version. However, May I raise my concern over complexity that stacks up and may deter simplicity concern (simplicity of use)?
Here is my original text:
twitter/typeahead.js#1425
I ran through this link http://code.runnable.com/UlXgeluakNULAAAv/create-an-autocomplete-input-box-with-typeahead-js-for-jquery-and-javascript and found out that the old version takes less to perform a simple task, without having to use Bloodhound. But maybe in this forked Typeahead, you already fixed it?
I'm using Bloodhound as much as I use Typeahead, so I am not afraid of having to use it but it's just my constructive query. Your input is appreciated.
Regards,
I tried hacking around with a bit but didn't get far and thought I'd ask before burning a day. I'd like to set up an array of common words and/or phrases and tell bloodhound to skip them when tokenizing.
Data: "Marbles 101 Article"
Ingore list: how, do, you, use, the, a, an...
Search string: "How do you use marbles"
Tokenizer: How do you use marbles
Hurray! User gets "Marbles 101 Article"
I just replaced "twiter/typeahead.js" with this repository this morning, hoping to resolve an issue. But, instead, it won't load anymore.
I installed the component using bower (i.e. it changed "typeahead.js": "^0.11.1"
to "typeahead.js": "corejs-typeahead#^0.11.1"
in my bower.json
file).
I reviewed my build to make sure the exact same file (i.e. typeahead.bundle.min.js
) is referenced in my dependencies (all seems to be unchanged). Launched the app, and I get RequireJS to throw "Uncaught Error: Load timeout for modules: typeahead"
.
My RequireJS config is declared as such :
require.config({
...
paths: {
...
'typeahead': 'path/to/typeahead.bundle.min',
'bloodhound': 'path/to/typeahead.bundle.min',
...
}
});
Has this happened to anyone? How to resolve this?
as reported a while back on jharding's repo, typeahead:render takes the wrong arguments:
twitter/typeahead.js#1444
twitter/typeahead.js#1207
this is still not fixed here.
Hi,
I faced an issue with caching internal search index structure inside localStorage
. The problem is, when you change tokenized fields, nothing really happens — old structure is used and you need to manually clear localStorage
.
So, it's not too critical, but I spent several hours to understand what's happening.
Perhaps it would be better to put the trie structure in sessionStorage
or somehow mark this thing in the documentation.
I've local elastic search server, install and running.
I instanciate 2 bloodhound object followig examples
If I use output as is, I have my results from my 2 datasource, no trouble.
When I want to use, remote: transform or filter option, to format the data, for using a custom template, I've trouble, the 2 template never get call.
Here's my code :
First bloodhound :
var nameSuggest = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace,
queryTokenizer: Bloodhound.tokenizers.obj.whitespace,
identify: 'nameSuggest',
sufficient: 50,
remote: {
url: 'http://localhost:9200/test2/_suggest?pretty',
prepare: function (query, settings) {
settings.type = "POST";
settings.contentType = "application/json; charset=UTF-8";
search_payload = {
"suggest": {
"text": query,
"completion": {
"field": "suggest"
}
}
};
settings.data = JSON.stringify(search_payload);
return settings;
},
transform: function(response) {
return $.map(response.suggest[0].options, function (option) {
return {
optionText: option.text,
optionId:option.payload.id
};
});
}
}
});
Second dataset:
var mailSuggest = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace,
queryTokenizer: Bloodhound.tokenizers.obj.whitespace,
identify: 'mailSuggest',
sufficient: 50,
remote: {
url: 'http://localhost:9200/test2/_suggest?pretty',
prepare: function (query, settings) {
settings.type = "POST";
settings.contentType = "application/json; charset=UTF-8";
search_payload = {
"suggestMail": {
"text": query,
"completion": {
"field": "suggest2"
}
}
};
settings.data = JSON.stringify(search_payload);
return settings;
},
transform: function(response) {
return $.map(response.suggestMail[0].options, function (option) {
return {
optionText2: option.text,
optionId2:option.payload.id
};
});
}
}
});
And typeahead:
jQuery('#topSearch').typeahead({
name:'topSearch',
hint: true,
highlight: true,
limit: 20
},
{
name: 'nameSuggest',
display: 'data',
source: nameSuggest,
templates: {
header: '<div><h3 class="">Noms</h3></div>',
suggestion: function (data) {
console.log("Name");
return '<div>'+data.optionId+' - '+data.optionText+'</div>';
}
}
},
{
name: 'mailSuggest',
display: 'data',
source: mailSuggest,
templates: {
header: '<div><h3 class="">Mails</h3></div>',
suggestion: function (data) {
console.log("Mail");
return '<div>'+data.optionText2+'</div>';
}
}
}
);
When I do :
console.log(nameSuggest);
console.log(mailSuggest);
I've two separate object, with unique names (the identify option) :
Bloodhound { identify="nameSuggest", sufficient=50, local=[0], plus...}
Bloodhound { identify="mailSuggest", sufficient=50, local=[0], plus...}
but, in the remote part of each object I can see the transform and prepare section with the two object names.
If I remove transform option from both bloodhound instances, and templates for typeahead, it works, and I'v suggestions.
If I remove transform of the second bloodhound instance and template associated, first results are displayed, withing the template, and second result are displayed raw, but it works.
If I let the second template in typeahead init, without bloodhound associated transform, the second template header is displayed, but the data undefined (normal behavior I suppose).
So, somehow, transform of the second bloodhound break something, but I can't figure out what, and how.
I don't know if I do something wrong, but, I've no ideas left :)
My json:
[
{id:1, name:'paul'},
{id:2, name:'jim'},
{id:3, name:'tom'},
{id:4, name:'medor'},
{id:5, name:'janzy'}
]
instance:
var bh = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '//localhost/data/names.json',
identify: function(datum){
return datum.id;
}
});
$('#name').typeahead({"highlight":true}, {
"name":"name",
"source":bh,
"display":"value",
"limit":10
})
event triggers:
$('#name').bind('typeahead:select', function(ev, suggestion){
console.log(suggestion);
})
suggestion
is an object which contain only the text value (i.e. name). How do i obtain the id?
Cross-posting twitter/typeahead.js#1344
In this example : http://twitter.github.io/typeahead.js/examples/#remote
If I type Chi, there's 1 network request and I see 1 suggestion i.e. Chicago. Now if I hit → or Tab key to autocomplete the hint, there's another network request sent for Chicago. How can I avoid this ?
Probably related to #188 & #548
( I'll add that the reason isn't just to save on network requests. I have an app that dynamically updates the request URL and I want a better control over which requests are sent. In the above case, an automatic request is sent using a stale URL )
milestone:v0.11.2
are these issues still valid to push out a release?
I was trying to use this fork instead of the twitter/typeahead.js but this is running a bower install after the npm install, I don't have bower in my CI and I do think that it shouldn't be a dependency when installing with npm. I noticed that bower is just installing jQuery and Jasmine and I think that Jasmine should be a devDependencie and jQuery can be installed as NPM dependency. If you guys agree with that I can open a PR with the changes.
I have a weird problem where I'm getting no results for certain queries. I've verified the server is returning the correct data, but typeahead is acting like there are no results (shows the notFound template). My data looks like this:
[
{"id":"123","name":"BRADLEY BEECH"},
{"id":"456","name":"BRADLEY SMITH"},
{"id":"789","name":"BRADY BLACKBURN"},
{"id":"234","name":"BRADY FINN"}
]
But when I search for BRAD
, I get no results. BRA
, BRADL
, and BRADY
work fine. I have also discovered that CARR
doesn't work while CAR
does. But, other 4 character queries work fine, as well. So, I'm very confused!
Here's my setup:
$('#patronLookup [name=query]').typeahead(null, {
name: 'patron-lookup',
limit: 10,
source: new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name']),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/patron/search?query=%QUERY',
wildcard: '%QUERY'
}
}),
templates: {
suggestion(p) {
return '<div>' + p.name + '</div>'
},
notFound: 'No results found!'
},
display(p) {
return p.name
}
}).on('typeahead:select', (e, o) => {
location.href = '/patron/' + o.id
});
Has anyone else experienced this?
I have the following template code running fine with v0.10.5:
suggestion: function(data) {
return '<p><div class="tt-name">' + data.name + '</div><span>review</span></p>';
}
In 0.10.5 the whole template is rendered inside the suggestion element. In v0.11.1 this is not rendering at all. If I remove the p tags it renders, but the outer template element and attributes (eg the tt-name class) are added to the parent tt-suggestion div.
Solution is to wrap the template in an extra div.
Am I missing something with my setup? Is this behavior by design or is this a bug?
Cross-posting this from https://github.com/twitter/typeahead.js
The docs are split in two with no page explaining how the two fit together, which is how they will be used most of the time.
More importantly, there's no mention whatsoever in either page of the ttAdapter
method, even though most users specify engine.ttAdapter()
as their source in the typeahead, as is done here. This is a key function as it runs the engine's search:
__ttAdapter: function ttAdapter() {
var that = this;
return this.remote ? withAsync : withoutAsync;
function withAsync(query, sync, async) {
return that.search(query, sync, async);
}
function withoutAsync(query, sync) {
return that.search(query, sync);
}
},
Hello,
We use typeahead.js version '0.11.1'.
Our code looks like:
this.bloodhound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: this.identify.bind(this),
local: this.localData,
remote: {
url: this.searchUrl,
wildcard: this.searchWildcard
}
});
$(this.input).typeahead({
highlight: true,
hint: true,
minLength: 1
}, {
display: this.toString.bind(this),
source: this.bloodhound,
limit: 5,
templates: {
pending: this.loadingTemplate,
empty: this.emptyTemplate
}
});
As you can see we have no prefetch/cache enabled, but we have some local data before initialization.
If I type something and exactly 5 items are returned I see "No items found" message (this.emptyTemplate). But there were 5 items found!
I think that this issue is caused by Dataset.update() function logic:
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));
Thus it appends zero items.
BTW, typeahead is awesome! Thanks!
I tried to do this with your Default Suggestions example, but in my case data set is dynamic. Because of that this is not suitable. Also some users may have no idea what to type in textbox to load the suggestions... Sometimes user have to try inputting A to Z to get a suggestion..
Using typeahead 0.11.1.
I have a remote endpoint that always returns 0-20 results. I don't use prefetch and I don't use local. I'm not using bloodhound, so there's no filtering or caching going on there. Nevertheless, I get really strange numbers of results from typeahead:
limit: 19
: Seems to work most of the time, but sometimes it returns only the first two results.limit: 20
: lots of queries don't give me any results. I believe this is due to the number of results being equal to limit
, as in issue #30.limit: 30
: I get ten results, even when my remote returned 20. No clue why.I honestly don't know what's going on with it at this point, but messing around with limit makes my result count change in all kinds of weird ways.
It seems like this plugin is locked down. Its a shame that twitter didn't allow for customisation.
I am now finding very difficult to intercept the XHR request. The typeahead sometimes responds with 401 if your session has timed out. I would like to intercept it and return the user to the login screen.
I have tried:
$(document).ajaxComplete(function(event, xhr) {
if(xhr.status == 401){
window.location.reload();
}
});
.bind('typeahead:asyncreceive', function(event , a ,b){
//none of these vars are useful. - event object doesn't seem to contain the XHR
});
I have also tried numerous settings in bloodhound / typeahead, but these appear to have been phased out:
twitter/typeahead.js#1029
http://stackoverflow.com/questions/23985898/twitter-typeahead-bloodhound-reutilization-how-do-i-show-a-loading-gif-for-th
Starting to wish I picked a different library :/
It would be nice to enable automatically selecting the first search result, this actually used to happen in typeahead in the past.
How I envision this to work is that one would intialise typeahead with an autoSelect
option set to true
(defaults to false
).
Will the library be added to the Nuget repository?
The typeahead:selected event, when triggered, used to pass the name of the dataset of the item selected as the third parameter, but it doesn't anymore for the typeahead:select event. How do we know the name of the dataset the selected item belongs to?
I originally posted here since I didn't realize this was the maintained fork.
I understand that Bloodhound and Typeahead are decoupled and in my particular case, the database is already providing ranking for the results, so I don't really need Bloodhound. However, I'd like to be able to throttle GET requests when typing. Is there some way to do it without Bloodhound? This is what I have so far:
$('.typeahead').typeahead({
highlight: true,
hint: false,
}, {
name: 'search',
display: 'value',
limit: 10,
source: function(query, syncResults, asyncResults) {
$.get('http://localhost:8000/search/' + query, function(data) {
data = $.map(data['values'], function(value) {
return {
value: value
};
})
asyncResults(data);
});
}
})
Assuming it is not possible to do it without Bloodhound, what is the minimal setup needed to provide rateLimitBy
, rateLimitWait
without unnecessary additional work.
Thank you
When using remote with bloodhound the template "notFound" is being overwritten by "suggestion" - why?
Im not sure how many of you install this package through bower, but when i do it installs the entire git directory into my project folder. Anyone against adding the ignore attribute in the bower.json so that when you install the package you only get the contents in the dist directiory
This pull request seems to be not merged, twitter/typeahead.js#1207
It is a very important bugfix
I am implementing typeahead search using typeahaead.js but as type in typeahead searchbox, in suggestions dropdown each records is coming twice.I checked the datasource(that is POST api call),it has only unique records.where am I doing wrong?Any help or relevant links.
I asked this on SO also..not getting any help
http://stackoverflow.com/questions/35320812/duplicate-records-coming-in-typeahead-search
similar issue discussed here twitter/typeahead.js#298
The current typeahead:change
only fires on blur.
I want to be able to bind a callback to any changes to the input text. So an event would fire for every key press while focused on the input element. There appears to be no way to do this after digging through the source.
This is an issue I already reported, yesterday, but since it also applies to this branch (which is apparantly the active branch), I'm also reporting it here.
Hi, of the 12 jobs running upon every Pull-request commit, none of the browser specific tests run!
Only the unit-test runs.
For example on #18, the tests ran, but only travis build 26.1 actually ran the test suite.
The others (browser based) had the following line in the output:
Not running any tests
which you can see for instance in travis build 26.2 and all the others in the travis build list for #18.
The line in test/ci
https://github.com/corejavascript/typeahead.js/blob/master/test/ci#L5
elif [ "$TRAVIS_SECURE_ENV_VARS" == "true" -a "$TEST_SUITE" == "integration" ]; then
evaluates to
+'[' false == true -a integration == integration ']'
which must mean that "$TRAVIS_SECURE_ENV_VARS"
is not set.
Who can help setting up the browser tests again?? I'd like to help but am in doubt about who has access to setting it up?
I have problems getting saucelabs to run our test suite (it was added by @jharding in twitter/typeahead.js project back in 2014, but broke at some point in time).
Now, some of the problem is covered by #20 and #21. But actually being able to run the integration tests locally would help so that we can see and debug errors with the actual suite.
The file integration/test.js
is the actual test, but also sets up Saucelabs-specific variables.
The task will be to make a split, so that we can run a simple task locally (which probably could use Phantom).
For example:
npm run test:integration
Noticed that pulling the module from NPM wasn't working so I went ahead and forked this repo and put it up on NPM.
It seems as though most of the maintainers here are just that - we're open to PRs, but lack time/desire to implement major features.
If this is the case, we should update the guidelines to let people know that feature requests will likely not be taken on, and that PRs are the best way to get new features in.
Thoughts @corejavascript/collaborators ?
So .. given a data set of:
One
Two
Three
Searching for say "T" will return Two and Three
But searching for "w" which is found inside Two, does not yield any results
Is it possible to easily enable substring matching in Bloodhound?
Hi, I saw that this suppose to be the right place to discuss about typeahead. Recently I start to work with this in my meteor app, I'd posted this question into the meteor-typeahead project too. What I want to know (or do, if it is possible) is if there is a way to set like: "only fetch results after type X symbol" in addition it would be more powerful if we have a way to scope the source using the trigger symbol like:
Bring me the tags after type #
Bring me the users after type @
If there is a way could someone throw me a link here? or a simple example. Otherwise, I will be more than happy to help to do so.
I am really struggling with trying to grab a reference to the input field. Internally there seems to be a this.$input
that should relate the the current input field. However, this isn't accessible through the API (to my knowledge) and all references to this
return the window
object.
The problem I am finding is due to the fact that I'm binding to multiple inputs, this is clearly not the default behaviour that the twitter devs intended, but I believe it makes sense.
var data = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: function(obj) { return obj.objectId; },
remote: {
url: '/team/management/suggest',
prepare: function(query, request){
console.log(this); // Bloodhound object
var name = $(":focus").attr("name");
request.url = request.url + '?'+ name +'=' + query;
return request;
}
}
});
$('[role="typeahead"]').typeahead({
minLength: 2,
highlight: true,
classNames: {
wrapper: "suggestion-wrapper"
}
}, {
name: 'players',
display: 'name',
source: data,
limit: 100,
templates: {
suggestion: function(obj){
console.log($(this)); // Window object
var name = $(":focus").attr("name");
if(name == "form_team_manage_ground"){
return '<div class="clearfix"><strong>'+ (obj.name || obj.street) +'</strong> <span class="pull-right">'+ (obj.postcode || "") +'</span></div>';
}
return '<div><strong>'+ (obj.name) +'</strong></div>';
},
notFound: function(obj){
console.log(this); // Window object
var name = $(":focus").attr("name");
if(name == "form_team_manage_ground"){
return '<div class="tt-suggestion tt-selectable" data-action="add_ground"><strong>Add Ground</strong></div>'
}
return '<div class="tt-suggestion tt-selectable" data-action="add_player"><strong>Add Player</strong></div>';
}
}
})
This was working well, until the latest release of Safari, it seems that :focus
doesn't populate until after the suggestion engine kicks in, this means that I get undefined
.
I would like for the input field to be exposed so that we don't need to rely on :focus
.
Can somebody point me in the right direction as this library's source seems highly complex?
Cheers.
Hello,
I use typeahead.js version '0.11.1'. for two depended input fields like "street" and "building".
When we got the value of field "street" then we can make a query for filed "building". It works fine in all browsers, even in mobile. But not in Mozilla Firefox (in adnroid version too). In firefox there is no action in field "building" after we made choose in field "street". But, if we try in second (third,....) time then it works...until next page update.
I founded the way to fix it, but I think it's not the right way.
Sorry for my english ;-)
Problem part of code looks like:
var updateStates = function () {
var streetValue = currentStreet; //Doesn't work in Firefox without this line
var streetValue = streetInput.val (); //Works fine in all other browsers
var buildingValue = buildingInput.val ();
var badStreet = streetValue.replace (/\s/g, '').length < STREET_MIN;
if (badStreet || buildingValue.replace (/\s/g, '').length < BUILDING_MIN || (streetValue == lastStreetName && buildingValue == lastBuildingName)) {
btnDisabled = true;
searchButton.attr ('disabled', 'disabled');
} else {
btnDisabled = false;
searchButton.removeAttr ('disabled');
}
if (badStreet)
setDisabled (buildingInput, true);
else
setDisabled (buildingInput, false);
};
And here we got the problem function
streetInput
.typeahead (null, conf ('street', 'ajax.php?load=streets&query=%QUERY'))
.on ('typeahead:select', function (event, street) {
setStreet (street); //Doesn't work for first time on page load in Firefox
buildingInput[0].focus ();
}).on ('change keyup', function () {
if (currentStreet)
setStreet (null);
else
updateStates ();
setupBuildingAutocomplete ('street_name=' + urlencode ($(this).val ()));
}).on ('keydown', keydown);
I use the typeahead (latest build, 9c2b65c) in a modal dialog. When I click the Esc
key the typeahead menu closes, but my modal dialog also closes (because it is set to close when Esc
is clicked.
Since this issue is very similar to the one solved in #13 (which solves the same propagation problem when selecting an entry with the Enter
key), I tried implementing the same for the Esc
key, by adding $e.preventDefault()
and $e.stopPropgation()
in _onEscKeyed()
(see d0371ed). However, this is not enough since my modal dialog binds to the keyUp
event and typeahead only listens for keyDown
.
Any ideas on how this should be solved. In order to truly prevent an Esc
key click to propagate, I do believe typeahead should stop propagation for both keyDown
and keyUp
. Could a solution be to call close()
on keyUp
instead and simply suppress keyDown
- as long as the menu is open of course?
This fork is absolutely awesome! 💃
...
This issue can be closed xD
The read me contains 404 links to "Download the latest dist files individually:"
I am trying to set the value of a text field that is being used as typeahead. Because I don't want to trigger a query from Bloodhound, I'm using this line
element.data('ttTypeahead').input.setQuery(newValue, true);
However, Bloodhound is still trying to fetch some data, even though the silent
option is being passed. In fact, typeahead:asyncrequest
is still being fired, but with a single argument. I tried debugging, and it seems that the event is being called with dataset = undefined
, which cause this behavior.
The point is, how to set the value of the input field without triggering the suggestion menu to open, or even Bloodhound from performing an async request?
All and all, there is a problem at the moment and things are not working as expected.
Since the original repository is no longer being maintained, I would suggest separating this into its own repository along with working bower and npm packages.
As to how to do it, GitHub says to contact support:
To detach the fork and turn it into a standalone repository on GitHub, contact GitHub support.
From #3
I don't really know how we should handle this. 'typeahead.js' is currently registered for the abandoned twitter repository's. @rwjblue said in his comment:
As mentioned above, we are not to remove/change any repos registered to Twitter.
So perhaps we should use 'typeahead' instead of 'typeahead.js'?
/cc @corejavascript/collaborators
I find the current whitespace and nonword tokenizers in Bloodhound useful but I think a simple edge ngram tokenizer (à la Elasticsearch) would be a great addition, and is very suited to autocomplete queries.
To clarify, given the input "Foo bar"
, the tokenizer would return the following:
["F", "Fo", "Foo", "b", "ba", "bar"]
I already submitted a PR to the previous Twitter repo here but then discovered it's no longer maintained. If you think it'd be worthwhile addition let me know and i'll submit another PR here.
I have bloodhound configured to fetch Json data, which it does very nicely.
// constructs the suggestion engine var bloodHound = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: 'http://localhost:9000/invoices%QUERY', wildcard: '%QUERY' } });
In addition, the three main custom events are bound to the function "handler".
ta.bind("typeahead:cursorchange", handler); ta.bind("typeahead:autocomplete", handler); ta.bind("typeahead:select", handler);
So almost everything works: if the user types in a string that matches part of a result and completes using tab, the autocomplete event fires and the correct item is selected. If the user uses the arrow keys or the mouse to select from the dropdown, that works. Even if the user types in the whole string matching a result but in the wrong case, and then presses tab, it works. BUT if the user types in a string that precisely matches the result, no event is fired and there is no direct way that I can find to get the data from the matching Json result into the form. I think this is a bug.
This fix bf60a90 doesn't seem to be included in the version of this library on rails-assets.org
Algolia was using typeahead.js until they switched to an in-house solution : algolia/autocomplete#5
Would it make sense to focus our energies on algolia branch or does this have a USP over it ?
Here is my code which worked fine. I updated because of the limit issue. Now it's not rendering correctly.
var custSearch = new Bloodhound({
datumTokenizer: function(d) { return d.tokens; }, //Bloodhound.tokenizers.obj.whitespace('fullname'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/com/franchise/customer.cfc?method=getNameSearch&query=%QUERY',
wildcard: '%QUERY'
}
});
custSearch.initialize();
$("#CustSearch").typeahead({
minLength: 3,
highlight: true
},
{
name: "Cust-Search",
source: custSearch.ttAdapter(),
limit: 25,
templates: {
empty: [
'<div class="empty-message">',
'No matches found',
'</div>'
].join('\n'),
suggestion: Handlebars.compile([
'<p class="user-type">{{type}}</p>',
'<p class="user-name">{{fullname}} {{#if company}}({{company}}){{/if}}</p>',
'<p class="user-info">{{info}}</p>',
'{{#if address}}<p class="user-info">{{address}}</p>{{/if}}'
].join(''))
}
})
.on("typeahead:select", onSelected);
here is how it is rendering
This is same issue as in twitter/typeahead.js#1363
here also not fixed :(
var suggest_autodiscovery__ip_nets = new Bloodhound({
queryTokenizer: Bloodhound.tokenizers.whitespace,
datumTokenizer: Bloodhound.tokenizers.whitespace,
local: ['127.0.0.0/8','192.168.0.0/16','10.0.0.0/8','172.16.0.0/12']
});
$('#autodiscovery__ip_nets').typeahead({
hint: false,
highlight: true,
minLength: 1
},
{ name: "suggest",
limit: 16,
source: suggest_autodiscovery__ip_nets
});
if I type '1', '12', '19' - results found,
but if I type '8', '0', etc - nothing
when I change to
datumTokenizer: Bloodhound.tokenizers.nonword,
queryTokenizer: Bloodhound.tokenizers.nonword
search is better, but anyway strange behavior:
'8' and '0' - now found,
but '6' or '68' - still NOT FOUND.
matchAnyQueryToken: true
- also does not help
I know that I can specify an empty template for each dataset, but I have 6 or 7 datasets and I would like to specify something to be displayed when none of the datasets have hits.
If I just type in "4q8nywrfxm", I don't want to see 6 datasets all saying that they can't find that text, I just want one message, specified at the typeahead level (not the dataset level).
Does that make sense?
I copied this over from the old repo which I was using until I realized it's no longer maintained. Sorry if this is a dup or if it was already fixed but I couldn't find that it was.
For performance, our backend does one query and groups the results in 2 sections, it seems like the plugin is built to do one query per section.
Simply put, this Git source hasn't fixed the issue that could be described as:
With Bloodhound engine data to search for California, we type 'c' and retrieves the state with typeahead (54 states data). but typing 'l', 'i', 'for', 'li',... does not include California as a selective option or even nothing found. Try it here with all examples EXCEPT for the very first one.
Source: my post at Twitter Typeahead git (search_index.js)
If your version based off this stale version, please have a look at my raised concern:
twitter/typeahead.js@7ed93f9#commitcomment-14598011
If the problem is on Trie data structure, could you change the node data method in search_index.js so as to fix it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.