summaryrefslogtreecommitdiffstats
path: root/common/html-coverpage/static/js/bloodhound.js
blob: ec2cbf6ce1a246efd7a7f32abbb152c30076d6ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

var states = new Bloodhound({
  remote: '/search/autocomplete/?q=%QUERY',
  datumTokenizer: function(d) {
    return Bloodhound.tokenizers.whitespace(d.value);
  },
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  limit: 15
});

// kicks off the loading/processing of `local` and `prefetch`
states.initialize();

$('#bloodhound .typeahead').typeahead({
  hint: true,
  highlight: true,
  minLength: 1
},
{
  name: 'states',
  displayKey: 'value',
  // `ttAdapter` wraps the suggestion engine in an adapter that                                        
  // is compatible with the typeahead jQuery plugin
  source: states.ttAdapter()
});


$('#search_input').bind('typeahead:selected', function(obj, datum, name) {      
  $("form").submit();
});