Skip to content

Instantly share code, notes, and snippets.

@GuillaumeBiton
Created August 12, 2012 08:18
Show Gist options
  • Save GuillaumeBiton/3330626 to your computer and use it in GitHub Desktop.
Save GuillaumeBiton/3330626 to your computer and use it in GitHub Desktop.
Bootstrap Typeahead bind to an array of objects (with or without) underscore.js

This is a quick setup of bootstrap typeahead when your source is an array of object :

$('.typeahead').typeahead({ 
	source: $.map(data, function(obj) { return obj[property]; }) 
});

if you use underscore.js :

$('#search').typeahead({
	source: _.pluck(data, property)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment