Will_paginate + jquery ui tabs

Hi

I am using jquery ui modal dialog. In this dialog box, I have two jquery ui tabs, each tab contains a div with a list of items that are paginated with will_paginate (rails).

I have a few questions:

  • When I click on a paginated page, my modal is closed, but do I have url /? page = 2
  • When I open the modal again, I am on the second page of my first tab, and if I click on the second tab, I am also on the second page, which is not needed

Thanks for your help.

+3
source share
1 answer

, , . ajax will_paginate, :
https://github.com/mislav/will_paginate/wiki/Ajax-pagination

RemoteLinkRenderer, . remote_link_renderer.rb :

class RemoteLinkRenderer < WillPaginate::LinkRenderer
  def prepare(collection, options, template)
    @remote = options.delete(:remote) || {}
    super
  end

  protected
  def page_link(page, text, attributes = {})
    @template.link_to_remote(text, {:url => url_for(page), :method => :get}.merge(@remote), attributes)
  end
end

, , , will_paginate :

<%= will_paginate @items, :renderer => 'RemoteLinkRenderer' , :remote => { :update => 'items_div'} %>

@items - , items_div - dom.

Google will_paginate remotelinkrenderer.

, , , . , view will_paginate, :param_name , :param_name=>:tab2_page. : http://rubydoc.info/gems/will_paginate/2.3.15/WillPaginate/ViewHelpers

+2

Source: https://habr.com/ru/post/1792024/


All Articles