Autocomplete works fine when searching with a single attribute, as indicated here .
Autocomplete with several attributes, such as (name, city, country), possibly through → (in accordance with this )
def autocomplete
Doctor.search(params[:query], autocomplete: true, limit: 10).map{|doctor| doctor.slice(:name, :city, :country) }
end
However, this leads to a drop-down list / auto-complete suggestions to show "undefined".
For type forward, I use:
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js"></script>
In the code it is referenced:
$( function () {
$("#search").typeahead({
name: "doctor",
remote: "/doctors/autocomplete?query=%QUERY"
});
});
Is there any change to the typeahead file's java file due to more than one set of returned data?
source
share