I have a input text which on keyup sends the ajax request and gives response to replace the content. My form looks like this;
= form_for(:search, :url => "/users/search", :remote => true) do |f|
= f.label :user, "Type to find users"
= f.text_field :user
The UsersController search action searches for the user based on the ajax data and it renders the search.js.erb template. My search action looks like this;
def search
@users = User.search(params[:user])
respond_to do |format|
format.js{}
end
end
Now, the search.js.erb template is simple which is as;
$('.users_info').html(<%=j render @users %>);
The response is correct if I look in the firebug but does not replace the content in the page. If I place alert, it alerts the user. Why am I not being able to replace the existing content in the page. Is there something that I am doing wrong ?
Is it realy necessary to use js.erb? It looks like in your case you may simply
If you really need, try: