ruby-on-railstwitter-typeahead

Uncaught ReferenceError: Bloodhound is not defined


I am using the type ahead address picker given here

1) Have included google map and typeahead. Jquery is added through a gem and referenced in application.js

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=en-US"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
<script type="text/javascript" src="https://rawgithub.com/sgruhier/typeahead-addresspicker/master/dist/typeahead-addresspicker.js"></script>

2)Have added input text

<input id="address" type="text" placeholder="Enter an address">

3)Have instantiated address picker and typeahead.

$(document).on('ready page:load', function () {
    var addressPicker = new AddressPicker();

             $('#address').typeahead(null, {
                              displayKey: 'description',
                              source: addressPicker.ttAdapter()
              });

});

Solution

  • Issue was resolved here

    You should include typeahead.bundle.js which has typeahead + bloodhound. Look at demo here https://twitter.github.io/typeahead.js/examples/, they include https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js

    Needed to include https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js for typeahead + bloodhound, which fixed the issue.