I have this in my controller
@events = Newevent.search params[:search], suggest: true, partial: true, misspellings: {distance: 4}
and this in my model
searchkick suggest: [:eventname]
Now the autocomplete i have typeahead.js which looks like this
https://twitter.github.io/typeahead.js/ (would add but too large)
I havent put anything in my model as of yet for the autocomplete however the suggestions i have this in my view
<%= @events.try(:suggestions) %>
This returns nothing.
Ideas?
Sam
$(".autocomplete-cls").keyup(function() {
var value = $(".autocomplete-cls").val();
$("#query1").val($("#query_label1").val());
$.ajax({
method: "GET",
dataType: 'json',
url: "/properties/autocomplete",
data: { query: value },
success: function(msg){//console.log(msg);
var availableTags = msg;
$( ".autocomplete-cls" ).autocomplete({
source: availableTags,
select: function( event, ui ) {
$("#query1").val(ui.item.value);
$('#property_type, #price, #bed, #bath, #floor').val('');
setTimeout(function(){$("#query_label1").val(ui.item.label);$(".search_form1").submit();}, 100);
},
focus: function( event, ui ) {
$("#query_label1").val(ui.item.label);
}
});
}
});
});
Create a action for response with name auto-search
event = NewEvent.search(params['keyword']).map(&:name)
render :json => event