Last active
August 29, 2015 14:01
-
-
Save bcoe/8748123afc75129a9191 to your computer and use it in GitHub Desktop.
main.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var $ = window.jQuery = require('jquery'); | |
| var typeahead = require('typeahead.js'), | |
| npmUrl = 'https://www.npmjs.org'; | |
| $(document).ready(function() { | |
| // Create the engine, used to interact | |
| // with our search backend. | |
| var engine = new Bloodhound({ | |
| name: 'packages', | |
| local: [], | |
| remote: '/search?q=%QUERY', | |
| datumTokenizer: function(d) { | |
| return Bloodhound.tokenizers.whitespace(d.val); | |
| }, | |
| queryTokenizer: Bloodhound.tokenizers.whitespace | |
| }); | |
| engine.initialize(); | |
| // attach the typeahead extension to | |
| // our search box using jQuery. | |
| var typeahead = $('typeahead').typeahead({}, | |
| { | |
| name: 'states', | |
| displayKey: 'value', | |
| source: engine.ttAdapter() | |
| } | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment