Hi,
I have an index page with searchbox and with pagination, it worked well 
when I tried to make pagination with javascript, itworked for the first 
page but not the second
I think the problem is to pass the value of the search box to the script of 
pagination

here is my code:
------------------------------------------------------------------------------------
index.hmtl.erb

<%= text_field_tag 'q', params['q']  %>
<div id="posts" >   
        <%= render  'layouts/posts' %>
</div>
<% if !@posts.nil? %>
      <%= link_to 'Load More Posts', post_path(:page => @posts.next_page), 
:class => 'load-more-posts', :remote => true if @posts.next_page %>
 <% end %>
-----------------------------------------------------------------
_posts.html.erb
<% if !@posts.nil? && @posts.size > 0  %>
                <% @posts.each_with_index do |post| %>
                    <b><%= post.title %></b>
                    <p><%= post.body %></p>
                <% end %>
 <% end %>
-----------------------------------------------------


index.js.erb
$("#posts").append("<%= escape_javascript(render partial: "layouts/posts", 
:locals => { :posts => @posts }) %>");
---------------------------------------------------------------------------
post_controller.rb

*if !params[:q].nil?   *
      
      @posts = Post.find_with_q.paginate(:per_page => 10, :page =>  
params[:page])
      
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @posts }
        format.js
      end
end

--------------------------------------------------------------------------------


The problem with this code is thatI can't go to the next page beause the 
params q is null with ajax call
when I delete the condition it works well
thank you fo the help

rgds,



-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b53cd303-5228-4885-814b-44eaade8c4c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to