Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jharding
Last active May 31, 2020 09:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jharding/9458772 to your computer and use it in GitHub Desktop.
Save jharding/9458772 to your computer and use it in GitHub Desktop.
<div id="remote">
<input class="typeahead" type="text" placeholder="Oscar winners for Best Picture">
</div>
var bestPictures = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: '../data/films/post_1960.json',
remote: {
url: '../data/films/queries/%QUERY.json',
wildcard: '%QUERY'
}
});
$('#remote .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures
});
@BaqerNaqvi
Copy link

works perfectly in my case ! 👍

@jorgevilaca82
Copy link

what if I want to filter remotely by a value of another field? How can I achieve this?

@bkuhl
Copy link

bkuhl commented Feb 9, 2015

Is this outdated? It seems as though .typeahead() now only has 1 parameter: https://github.com/twitter/typeahead.js/blob/master/src/typeahead/typeahead.js#L16

@JoshvaR88
Copy link

I'm getting this error

ReferenceError: Bloodhound is not defined
var bestPictures = new Bloodhound({

@saiallu
Copy link

saiallu commented Nov 13, 2015

BaqerNaqvi... what is data model your are returning in query.json? Does anybody have working example for asp.net mvc application?

@ChetanBhasin
Copy link

Is there a way to send the query made by the user to the remote host for it to produce suggestions accordingly?

@blissjaspis
Copy link

thanks works perfect on laravel 5.4

@atifadib
Copy link

For a local json, what should be the url for remote?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment