I'm trying to get Twitter Typeahead+Bloodhound to work with Google's CSE.
So far, I've managed to get the results returning, but I'm not able to work out the datumTokenizer.
var results = new Bloodhound({
datumTokenizer: function(data) {
return Bloodhound.tokenizers.whitespace(d.value)
},
queryTokenizer: Bloodhound.tokenizers.obj.whitespace,
remote: {
url: "http://clients1.google.com/complete/search?client=partner&hl=en&sugexp=gsnos%2Cn%3D13&gs_rn=25&gs_ri=partner&partnerid=004914516364918182382%3Ayfqw09r4qvu&types=t&ds=cse&cp=3&gs_id=15&q=%QUERY&callback=showResults&duffCallback=?",
ajax: $.ajax({type:'GET',dataType:'jsonp',jsonp:'duffCallback'}),
filter: showResults
}
});
See the fiddle: http://jsfiddle.net/thugsb/3KAjh/
You'll see that I've got the results being returned from showResults() as an array. However, the call to showResults() from the filter:
doesn't seem to be doing anything, as removing that line has no effect. So I'm not quite sure what is going on.
Note the duffCallback is what I worked out to do from reading this question. If there's a better way to make this work I'm all ears!