Hi there!
I need some help, I'm new to rjs + will_paginate and don't know how
to
solve this problem.
The application apparently is working fine, the partial is rendered
by the javascript, the pagination works fine, but sometimes, when I
hit the next page number or " next >>", it reders the  code below.
Im using rails 2.3.8, ruby 1.8.7. and will_paginate 2.3.15
Thanks!
try { Element.update("search_professors", "
Professors  List
\n
\n\n\n\n\n\n  \n    Name Address Action \n
\n \n  \n \n    \n \n \n   \n  John  \n  \n \n  \n
\n \n  \n \n    \n \n \n   \n  Carl \n    \n  \n \n  \n
\n \n\n \n\n\n \n \n
\n
\n \n
\n\n
\n
\n
<< prev 1 2 next >>
\n
\n\n"); } catch (e) { alert('RJS error:\n\n' + e.toString());
alert('Element.update(\"search_professors\", \"
Professors  List
\n
\n\n\n\n\n\n  \n    Name Address Action \n
\n \n  \n \n    \n \n \n   \n  John  \n  \n \n  \n
\n \n  \n \n    \n \n \n   \n  Carl \n    \n  \n \n  \n
\n \n\n \n\n\n \n \n
\n
\n \n
\n\n
\n
\n
<< prev 1 2 next >>
\\n
\\n \\n
\\n\\n
\\n
\\n
<< prev 1 2 next >>
\\n
\\n\\n\");'); throw e }
My Controller:
def search_professors
  begin
   @professors =
User.search_for(params[:search]).paginate(:all,:conditions =>
{:professor => true},:page => params[:page], :per_page => 8)
  rescue => e
   flash[:error] = e.to_s
   @professors= User.search_for '*'
  end
   respond_to do |format|
      format.html
      format.js
    end
end
The view:
  <% tabnav :user do%>
  <% form_remote_tag :url => 'search_professors' do %>
      <%= text_field_tag :search, params[:search], :value => nil %>
      <%= submit_tag "Go", :name => nil , :disable_with => "Please
wait..."%>
  <%end%>
  <div id="search_professors">
      <%= render :partial => "course/professors_list" %>
  </div>
  <br/>
  <% end %>
The partial inside the view:
<h1> Professors  List</h1>
<% form_tag('/user/email_professors', :method => :post) do%>
 <% if [email protected]? %>
    <table class="course"  id="mats">
       <tr class="header">
            <th></th> <th>Name</th> <th>Address</th> <th>Action</th>
       </tr>
          <% @professors.each do |professor| %>
            <tr class="<%= cycle('odd', 'even') %>">
                 <% if !professor.nil? %>
                      <td width="5%" > <%= check_box_tag
"user_emails[]" , professor.email  %>  </td>
                 <% end %>
                 <td><%=image_tag   professor.photo.url(:mini) %></
td>
                 <td width="40%">  <%= professor.spec.full_name %></
td>
                 <td width="40%">  <%= professor.address.address %>
</
td>
            </tr>
        <% end %>
     </table>
  <% else %>
       <br></br>
       <h4><i>No results!</i></h4>
       <br></br>
  <% end %>
<% end %>
   <div  style="font-size: small">
        <%= will_paginate @professors %>
   </div>
My JavaScript file
search_professors.rjs
page.replace_html :search_professors, :partial => "course/
professors_lista", :object => @users

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to