Ajax Search Form Issue

Hi,

I tired ajax search form followed railscast 240 but when i applied the
same
code from railscast tutorial(ajax code), i have an issue the search
functionality not working, i’m not good in ajax, can any one suggest
what
wrong functionality i did.

Here i attached some screen short for understanding purpose.

Here the ajax code:

  • jQuery("#projects_search input").keyup(function() {
    jQuery.get(jQuery("#projects_search").attr(“action”), jQuery("#
    projects_search").serialize(), null, “script”);
    return false;
    });

In my projects controller:

@status = params[:status] || 1
scope = Project.status(@status)
scope = scope.like(params[:name]) if params[:name].present?
@search = scope.visible.map {|p| p.self_and_ancestors
}.flatten.uniq.sort_by(&:lft)
respond_to do |format|
format.js {
@search = @search.select {|p| p.level == params[:level].to_i and
p.parent_id == params[:parent_id].to_i }.sort_by(&:name)
render :partial => ‘level’, :locals => {:search => @search,
:start_level => params[:level]}, :layout => false
}

In my app/views/projects/index.js.erb

jQuery("#level").html("<%= escape_javascript(render(“level”)) %>");

In my app/views/projects/index.html.erb

*<%= form_tag({}, :method => :get, :id => “projects_search”) do %>
<%= text_field_tag ‘name’, params[:name], :size => 30 %>
<% end %>

<%= render :partial => 'level', :locals => {:search => @search, :start_level => 0} %>
* In my render partial app/views/project/_level.html.erb *<% search.each do |project| %> <% level = start_level.to_i %> <% if User.current.allowed_to?(:view_project, project) %> onclick="location.href = '<%= project_path(project) + ((project.module_enabled?(:issue_tracking))?"/issues":"") %>';"<% end %>>

xxxxxxxxxxx

<% end %>*

Joshua :slight_smile:
RoR