Hello everyone, I am having an issue with the will_paginate gem, i have recently added AJAX and JS to refresh the div with paginate without refreshing the page. I followed online examples and successfully got it working, however the "previous" button and the first page are not shown as links, and can not be clicked. All other pages are in working order, and refreshes fine except the first. Controller: def index @tickets = Ticket.where(''archived = ?'', "False").where(''closed = ?'', "False").order(sort_column + " " + sort_direction).paginate(:page => params[:page] || 1, :per_page => 12) respond_to do |format| format.html # index.html.erb format.json { render json: @tickets } format.js end end View: <div id="list"> <%= render :partial => ''customerList'' %> </div> <%= will_paginate @tickets, :previous_label => "← Previous", :next_label => "Next →" %> <script> $(document).ready(function() { $(''.paginate a'').attr(''data-remote'', ''true''); });</script> Index.js.erb: $(''#list'').html(''<%=escape_javascript render :partial => "customerList" %>''); $(''.paginate a'').attr(''data-remote'', ''true''); If anyone could shine some light on why this issue is occuring, I''d really appreciate it. Thanks! -- Posted via http://www.ruby-forum.com/. -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Could you provide rendered HTML for the Previous button? My idea would be it is disabled somehow and you got to alter that part of HTML too with your code in index.js.erb; i.e. it is rendered as non-link for the first (default) rendering of the pagination, and that element has no idea you''re already "at page 2". Better yet provide what the HTML of Prev looks like when you are at page number 1, and page number 2 (without Ajax functionality). That should give you and me insight in what has to change for that Prev link to become active. 2013/3/28 Colton Pl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> Hello everyone, I am having an issue with the will_paginate gem, i have > recently added AJAX and JS to refresh the div with paginate without > refreshing the page. > I followed online examples and successfully got it working, however the > "previous" button and the first page are not shown as links, and can not > be clicked. > All other pages are in working order, and refreshes fine except the > first. > > Controller: > > def index > @tickets = Ticket.where(''archived = ?'', "False").where(''closed = ?'', > "False").order(sort_column + " " + sort_direction).paginate(:page => > params[:page] || 1, :per_page => 12) > > respond_to do |format| > format.html # index.html.erb > format.json { render json: @tickets } > format.js > end > > end > > View: > > <div id="list"> > <%= render :partial => ''customerList'' %> > </div> > > <%= will_paginate @tickets, :previous_label => "← Previous", > :next_label => "Next →" %> > > <script> > $(document).ready(function() { > $(''.paginate a'').attr(''data-remote'', ''true''); > });</script> > > Index.js.erb: > > $(''#list'').html(''<%=escape_javascript render :partial => "customerList" > %>''); > $(''.paginate a'').attr(''data-remote'', ''true''); > > > > If anyone could shine some light on why this issue is occuring, I''d > really appreciate it. > Thanks! > > > >-- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Page Source - With Ajax Functioning <div class=''paginate''> <div class="pagination"><span class="previous_page disabled">← Previous</span> <em class="current">1</em> <a rel="next" href="/tickets?page=2">2</a> <a href="/tickets?page=3">3</a> <a href="/tickets?page=4">4</a> <a href="/tickets?page=5">5</a> <a class="next_page" rel="next" href="/tickets?page=2">Next →</a></div> </div> It does appear that the previous button is disabled on page load, and the first page is not a link. After changing the page number, : Page Source - Page 2 - With Ajax <div class=''paginate''> <div class="pagination"><span class="previous_page disabled">← Previous</span> <em class="current">1</em> <a rel="next" href="/tickets?page=2">2</a> <a href="/tickets?page=3">3</a> <a href="/tickets?page=4">4</a> <a href="/tickets?page=5">5</a> <a class="next_page" rel="next" href="/tickets?page=2">Next →</a></div> </div> The first page link still shows the "current" class, the "Next" button stays linked to page #2, and the previous is disabled. (Without Ajax, the will_paginate was fully functional, including the "Previous and Next" buttons) -- Posted via http://www.ruby-forum.com/. -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
I think its better to add <%= will_paginate @tickets, :previous_label => "← Previous", :next_label => "Next →" %> in the partial file (customerList). I hope it may be useful On Thu, Mar 28, 2013 at 8:57 PM, Gintautas Šimkus <dihitales-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Could you provide rendered HTML for the Previous button? My idea would be > it is disabled somehow and you got to alter that part of HTML too with your > code in index.js.erb; i.e. it is rendered as non-link for the first > (default) rendering of the pagination, and that element has no idea you''re > already "at page 2". Better yet provide what the HTML of Prev looks like > when you are at page number 1, and page number 2 (without Ajax > functionality). That should give you and me insight in what has to change > for that Prev link to become active. > > > 2013/3/28 Colton Pl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > >> Hello everyone, I am having an issue with the will_paginate gem, i have >> recently added AJAX and JS to refresh the div with paginate without >> refreshing the page. >> I followed online examples and successfully got it working, however the >> "previous" button and the first page are not shown as links, and can not >> be clicked. >> All other pages are in working order, and refreshes fine except the >> first. >> >> Controller: >> >> def index >> @tickets = Ticket.where(''archived = ?'', "False").where(''closed = ?'', >> "False").order(sort_column + " " + sort_direction).paginate(:page => >> params[:page] || 1, :per_page => 12) >> >> respond_to do |format| >> format.html # index.html.erb >> format.json { render json: @tickets } >> format.js >> end >> >> end >> >> View: >> >> <div id="list"> >> <%= render :partial => ''customerList'' %> >> </div> >> >> <%= will_paginate @tickets, :previous_label => "← Previous", >> :next_label => "Next →" %> >> >> <script> >> $(document).ready(function() { >> $(''.paginate a'').attr(''data-remote'', ''true''); >> });</script> >> >> Index.js.erb: >> >> $(''#list'').html(''<%=escape_javascript render :partial => "customerList" >> %>''); >> $(''.paginate a'').attr(''data-remote'', ''true''); >> >> >> >> If anyone could shine some light on why this issue is occuring, I''d >> really appreciate it. >> Thanks! >> >> >> >> -- > 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ---------------------------------------------------------------------------------------------------- Thank You. Best Wishes, BalaRaju Vankala, 8886565300. -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
I''m not 100% why, but that worked perfectly. Thanks so much! -- Posted via http://www.ruby-forum.com/. -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.