Ruby on Rails Twitter Typeahead implementation issue

98 views Asked by At

My organization recently upgraded an application to a Ruby on Rails environment, and in the process the Twitter Typeahead feature no longer functions. The Solr process runs fine (after some reconfiguration) but the issue seems to be related to the Javascript implementation.

The Typeahead bundle installed is 0.11.1 with JQuery 1.10.1.

Applicable gems installed for this application are sunspot (2.1.0), sunspot_rails (2.1.0), sunspot_solr (2.2.0, 2.1.0), and rsolr (1.0.12, 1.0.9).

Here is the code for the input that includes the typeahead function:

<input id="header_search" class="search__field" type="text" placeholder="Search project or site..."autocomplete="off">

Here is the Javascript from the application.js file:

$(function() {
$('#header_search').typeahead([
  {
        name: "contents",
        remote: "/contents/typeahead?search=%QUERY",
        template: $('#typeahead_template').html(),
        engine: typeahead_engine,
        limit: 4
    }
    ]).on("typeahead:selected", function(e, datum) {        
        window.location = datum.target
    })

Everything seems to be in compliance with the Twitter Typeahead documentation and the remote connection is setup similarly to the previous application version, but the feature is not working in browser for the upgraded application. Appreciate any guidance on how to get this working!

0

There are 0 answers