Rails 5 Live Search with Keyup losing input focus Turbolinks Rails 5 Live Search with Keyup losing input focus Turbolinks ajax ajax

Rails 5 Live Search with Keyup losing input focus Turbolinks


What was actually happening was that the JS would fire and my search form partial would get reloaded. So I changed this:

$("#search").html("<%=j render :partial => 'contacts/search' %>")$("#results").html("<%=j render :partial => 'contacts/results', locals: {contacts: @contacts} %>")

To This:

$("#results").html("<%=j render :partial => 'contacts/results', locals: {contacts: @contacts} %>")

And it works perfectly.