bloodhound

Twitter's typeahead + Bloodhound with JSON objects

╄→гoц情女王★ 提交于 2019-12-07 09:38:20
问题 I can't get it to work with JSON objects. I've followed multiple questions here on SO and none of the answers helped me. $(function() { var items = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, limit: 10, prefetch: { url: 'items.json', filter: function(list) { return $.map(list, function(item) { return { name: item.name, category: item.category, release: item.release, id: item.id }; }); } } }); items.initialize

remote autocomplete by typeahead works only on unique queries

 ̄綄美尐妖づ 提交于 2019-12-06 14:54:30
问题 I am having problem setting up typeahead with bloodhound on two fields - symbol and name. You can try live version on my DGI portfolio manager and autocomplete remote source here. Typeahead sometimes works and sometimes it does not. If I type symbols like "jnj", "mcd", "aapl" it works. However, when I type string from name like "corporation" and "inc" that have around 3000 objects with this name, it does not work. I doubt it is because it is loading, since json file is served quickly(under

Typeahead.js + Bloodhound remote data: how to get calling object reference?

本小妞迷上赌 提交于 2019-12-06 13:46:52
问题 I'm trying to DRY out some JQuery code that initializes a typeahead.js plugin that uses the Bloodhound suggestion engine with a remote data source. This is the code so far: var locsData = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: "/locations/search.json?q=%QUERY", ajax: { beforeSend: function(xhr, settings) { $("#typeahead1").addClass('loading-text'); }, complete: function(xhr, status) { $("

Use Meteor collections for Typeahead Bloodhound, preferably without making my own API

落花浮王杯 提交于 2019-12-06 08:36:50
问题 I want to build a tags input like the one in StackOverflow. I am trying to use Meteor collections as the remote or prefetch data for Typeahead Bloodhound because I want to eventually use Bootstrap Tokenfield. According to their documentation and examples, a url to the JSON data is absolutely required. How can I provide the data, preferably reactively, to Bloodhound? I have looked into the Meteor Typeahead package, but I can't figure out how to use it with the Meteor Tokenfield package. Below

Searchkick + Bloodhound + Typeahead for autocomplete

五迷三道 提交于 2019-12-06 05:29:53
问题 I am trying to implement a simple autocomplete feature for a single attribute. Model: searchkick text_start: [:name],autocomplete: ['name'] After reindexing the behaviour on the Rails console is ok . 2.2.0-p0 :002 >Doctor.search("a", autocomplete: true).map(&:name) gives the output- => ["a", "aa", "aaa", "aaaa"] After this i added the Autocomplete action to the controller and a new route to the routes.rb file. Controller: def autocomplete console.log("In auto") render json: Doctor.search

Why is my datumTokenizer never getting called?

谁说我不能喝 提交于 2019-12-05 21:21:24
I put a breakpoint inside the datumTokenizer function, but it never seems to get called. Why not? Does it work with remote-only data? var engine = new Bloodhound({ datumTokenizer: function(d) { return Bloodhound.tokenizers.obj.whitespace(d); }, queryTokenizer: Bloodhound.tokenizers.nonword, identify: function( obj ) { return obj.id; }, remote: { url: '/typeahead/%QUERY', wildcard: '%QUERY' }, limit: 5 }); $( '#city_or_zip' ).typeahead({ hint: true, minLength: 2 }, { display: function( data ) { return formatCityState( data ); }, source: engine.ttAdapter(), templates: { empty: 'No results found'

Twitter typeahead.js / Bloodhound (v 0.10.2): How to update the (local) source dynamically

会有一股神秘感。 提交于 2019-12-05 05:06:40
问题 In the below example, how should you update the (local) "source" after a selection was made ? The selected value should be deleted from the "source" (and eventually also be re-added, when necessary) so it can't be selected again. var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan',

remote autocomplete by typeahead works only on unique queries

假装没事ソ 提交于 2019-12-04 20:43:45
I am having problem setting up typeahead with bloodhound on two fields - symbol and name. You can try live version on my DGI portfolio manager and autocomplete remote source here . Typeahead sometimes works and sometimes it does not. If I type symbols like "jnj", "mcd", "aapl" it works. However, when I type string from name like "corporation" and "inc" that have around 3000 objects with this name, it does not work. I doubt it is because it is loading, since json file is served quickly(under 250ms on localhost). Firstly, I thought symbols work correctly and names are ignored. But I do get

Typeahead.js + Bloodhound remote data: how to get calling object reference?

好久不见. 提交于 2019-12-04 18:49:10
I'm trying to DRY out some JQuery code that initializes a typeahead.js plugin that uses the Bloodhound suggestion engine with a remote data source. This is the code so far: var locsData = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: "/locations/search.json?q=%QUERY", ajax: { beforeSend: function(xhr, settings) { $("#typeahead1").addClass('loading-text'); }, complete: function(xhr, status) { $("#typeahead1").removeClass('loading-text'); } } }, limit: 100 }); locsData.initialize(); $("#typeahead1")

How do I list objects for Typeahead.js and/or with the Bloodhound engine?

孤街醉人 提交于 2019-12-04 14:17:07
I'm having a hard time figuring out how to display a list of objects using typeahead with a json file as the source. None of my data is being displayed. I want to list the names, and use the other attributes for other things when selected. ../data/test.json [ {"name": "John Snow", "id": 1}, {"name": "Joe Biden", "id": 2}, {"name": "Bob Marley", "id": 3}, {"name": "Anne Hathaway", "id": 4}, {"name": "Jacob deGrom", "id": 5} ] test.js $(document).ready(function() { var names = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace("name"), queryTokenizer: Bloodhound.tokenizers