1

I'm using the typeahead.js library for search within my app. I've put together the following search but unfortunately at the end, I can't access this. Here's the current code:

$('#search-field').typeahead({hint:false, minLength: 2}, {
  configSetings: settings,
}).bind('typeahead:select', function(obj, datum) {
  this.history.pushState(null, `/term/${datum.permalink}`);
});

I've attempted to call .bind(this) to the typeahead:select event but when I do I end up with an error which states:

Uncaught TypeError: m.push is not a function

I have no idea how to resolve this. Any ideas? I'm using ReactJS, Webpack, and Typeahead.js.

Nick ONeill
  • 7,341
  • 10
  • 47
  • 61

1 Answers1

0

How about this:

$('#search-field').typeahead({hint:false, minLength: 2}, {
  configSetings: settings,
}).bind('typeahead:select', (function(obj, datum) {
  this.history.pushState(null, '', `/term/${datum.permalink}`);
}).bind(this));
shanonvl
  • 619
  • 4
  • 6