Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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

This comment has been minimized.

Copy link

@BaqerNaqvi BaqerNaqvi commented Jul 7, 2014

works perfectly in my case ! 👍

@jorgevilaca82

This comment has been minimized.

Copy link

@jorgevilaca82 jorgevilaca82 commented Jul 31, 2014

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

@bkuhl

This comment has been minimized.

Copy link

@bkuhl 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

This comment has been minimized.

Copy link

@JoshvaR88 JoshvaR88 commented Jul 23, 2015

I'm getting this error

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

@saiallu

This comment has been minimized.

Copy link

@saiallu 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

This comment has been minimized.

Copy link

@ChetanBhasin ChetanBhasin commented Mar 29, 2016

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

@blissjaspis

This comment has been minimized.

Copy link

@blissjaspis blissjaspis commented Jan 25, 2017

thanks works perfect on laravel 5.4

@atifadib

This comment has been minimized.

Copy link

@atifadib atifadib commented Jan 22, 2018

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
You can’t perform that action at this time.