Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added :remote option to will_paginate #100

Closed
wants to merge 2 commits into from
@dcrec1

Hi,

I added the remote option to will paginate, so in Rails3 we can do this:

will_paginate @records, :remote => true

and generate html like this:

<a data-remote=true ...>...</a>
@mislav
Owner

I'll think about it. This is only part of the solution, though. Users still have to implement the logic on the controller side, make a partial, organize all that in the view etc

@acesuares

I dont know about it. The only thing i had to do was add data-remote=true and it worked right away. Maybe you want a demo?

@sobrinho

Rails 3 handle this gracefully.

Maybe it's time to accept the pull request? :)

@ryanb

+1 on this. It stays consistent with Rails current helper method behavior in link_to and form_for.

@andres

+1 as well, in the meantime you can do:
$(".pagination").find("a").attr("data-remote", true);

@sobrinho

I'm using another approach because I don't want to run the same piece of javascript every time :)

  // will_paginate do not support link attributes yet.
  // See: https://github.com/mislav/will_paginate/pull/100
  $('.ui-modal .pagination a').live('click', function () {
    $.rails.handleRemote($(this));
    return false;
  });
@andres

yep, like it better, thx

@ronalchn

I see this pull request, and the referenced request, are both for the 2.3 version. The 3.0 version already includes this feature. Somebody should close this.

Incidentally, I've created a gem which will add AJAX, including all the client-side and controller logic with just a few simple changes. Adding AJAX to will_paginate

@amnesia7

@mislav, has this been committed yet (:remote => true), or if not, is there any sign of it being?

@mislav
Owner

Nope, won't pull this. Ajax pagination isn't as easy as adding :remote => true to links, and I don't want to make an illusion that it is and get everyone to enable Ajax in their pagination links blindly.

I welcome someone who creates a JS extension to will_paginate that handles Ajax pagination in a sophisticated manner, or writes a quality guide on our wiki.

@mislav mislav closed this
@kayakyakr

Switched to Kaminari because of this

@logorrhea

Why the hate? He has a valid point.

Also if you don't like the javascript workarounds mentioned above, will_paginate provides plenty of methods for creating your own pagination links (next_page, previous_page, total_pages, etc.), on which you can provide the remote: true option.

@rocknruby

For me, thats no hate statement, just a sign of teariness. :+1:
Yes it would be nice if the :remote option would be in the master. I understand the reasons from mislav. Sure there is always a workaround but thats not the point. Someone including me needs enough time to develop this feature completely, thats all. :)

@kayakyakr

I disagree that including :remote => true would give the impression that enabling ajax pagination was just a matter of doing so. Is doing :remote => true on any other link just a matter of putting that on to enable the full ajax suite to work? No! You have to still write some ujs method or return a bit of js code to be executed.

I personally feel that adding :remote => true would do just as expected and that is to set it so that the pagination links made an ajax call to the server and it would be up to the developer to handle the result.

@mislav
Owner

@kayakyakr Proper ajax pagination is so hard, that after doing all that coding it's absolutely trivial to add a global handler for pagination links with just few lines of code:

document.on('click', '.pagination a[href]', function(){ ... })

The reason why I want to force people to do that manually is because then they would have to think about it in more depth and add some history support with pushState or whatever. If you're doing ajax pagination by just making an ajax request and updating a paritial on the page, you're doing it wrong.

@kayakyakr

@mislav That doesn't force people to think about adding history support or anything of the sort, it simply asks them to create a workaround for something that is part of the current rails convention, that being that adding :data => :remote to something will cause it to make an ajax request. You still have to write the code:

$(document).on('ajax:success', '.pagination a', function(e, data){ ... });

By your logic, this would be enough to force them to consider adding history support and would have the added benefit of fitting in with current rails convention. Without that support, while will_paginate is a great gem, it breaks expectations, forces users to rewrite parts of the rails ujs library, and without customization makes will_paginate unsuitable for use in single-page webapps.

@yushun

Enable remote: true.
For those of us who know how to use ajax, we need this feature.
Currently I have to use
$(".pagination").find("a").attr("data-remote", true);
which is not the ideal solution.

@davidsm

I must admit I don't understand why remote pagination is a special case different from adding remote: true to regular links
Short example

<ul id="paginated-list">
  <%=render 'list' %>
</ul>

<%= will_paginate @paginated_stuff, remote: true %> (lets pretend this works)

List partial:

<% @paginated_stuff.each do |p| %>
  <li>p.whatever</li>
<% end %>

Set controller to the regular @paginated_stuff = Model.paginate(params[:page])

action.js.erb
$(#paginated-list).html("<%=escape_javascript(render 'list') %>");

And that's it. Works wonders (well, it would if I could just write remote: true instead of having to monkey patch will_paginate first), and is identical to how I usually handle ajax links.

@mislav
Owner

I must admit I don't understand why remote pagination is a special case different from adding remote: true to regular links

Consider the following scenarios:

  • Suppose the pagination links are below the 30 rendered items per page. The user scrolls to the bottom of the page and follows the ajax link to the next page. As expected, the 30 items are replaced with the next 30 items—with the newest on top—but you are still scrolled to the bottom of the page. You are forced to scroll back up to continue reading.

  • Suppose you follow the ajax link to the next page. The contents of the page updates, but the current URL does not. If you now share the URL with someone, they won't see the same content you're looking at.

  • Suppose you follow the ajax link to the next page. Now use the Back button in your browser. You would expect to be returned to the previous page, but in fact it takes you too far back.

  • Suppose you follow the ajax link from page 1 to page 2, then you follow a non-ajax link to another page. Now when you use the Back button, you expect to be taken to page 2, but you'll most likely be shown page 1. (This behavior varies between browsers & HTML caching settings.)

  • What happens if the ajax request results in a server error, e.g. due to a Ruby exception coming from the view template when rendering a specific entry? If nothing is explicitly catching these events in JS, the page doesn't get updated and neither the user nor the developer is shown any information about the error.

  • How is the user shown that the page is in the process of loading after they clicked? By default, there is no loading indicator, so the user doesn't get feedback that their action got registered.

Until you are able to predict and solve the above scenarios, don't even think of Ajax pagination. I make will_paginate to enable developers to provide a good pagination experience for their users, and it wouldn't make sense to add a feature that—by default—ruins this experience. I don't want to give my users a free gun to shoot themselves in the foot.

@davidsm

Fair enough, although those issues are common for any use of data-remote.

For those who finds this page when searching for the feature and feel like the issues mentioned can be handled or aren't problematic for their particular site, here's one way of monkey-patching in the feature

      module RemotePaginator
       class LinkRenderer < WillPaginate::ActionView::LinkRenderer
       private
       def link(text, target, attributes = {})
         if target.is_a? Fixnum
           attributes[:rel] = rel_value(target)
           target = url(target)
         end
        attributes[:href] = target
        attributes["data-remote"] = true #This is added
        tag(:a, text, attributes)
      end
     end
   end

And in a helper

 def remote_paginate *params
    params[1] = {} if params[1].nil?
    params[1][:renderer] = RemotePaginator::LinkRenderer
    will_paginate *params
  end

Use like <%= remote_paginate @stuff %> in place of will_paginate
Use will_paginate like normal when you don't want remote links

@kayakyakr

Sorry for the delayed response. Those are all issues, true, but they are shared by any remote: true link or form. Your gem still breaks Rails convention for remotes.

I have since switched to https://github.com/amatsuda/kaminari

@bcackerman

+1 to this $(".pagination").find("a").attr("data-remote", true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2011
  1. @dcrec1
Commits on Jun 25, 2011
  1. @dcrec1

    fix broken "Pagination 101" link

    authored dcrec1 committed
    closes #102
This page is out of date. Refresh to see the latest.
View
2  README.rdoc
@@ -98,7 +98,7 @@ are {showcased online here}[http://mislav.uniqpath.com/will_paginate/].
More reading about pagination as design pattern:
-* {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101]
+* {Pagination 101}[https://gist.github.com/622561]
* {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/]
* {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination]
View
118 examples/index.haml
@@ -1,69 +1,69 @@
!!!
%html
-%head
- %title Samples of pagination styling for will_paginate
- %link{ :rel => 'stylesheet', :type => 'text/css', :href => 'pagination.css' }
- %style{ :type => 'text/css' }
- :sass
- html
- :margin 0
- :padding 0
- :background #999
- :font normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif
- body
- :margin 2em
- :padding 2em
- :border 2px solid gray
- :background white
- :color #222
- h1
- :font-size 2em
- :font-weight normal
- :margin 0 0 1em 0
- h2
- :font-size 1.4em
- :margin 1em 0 .5em 0
- pre
- :font-size 13px
- :font-family Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace
+ %head
+ %title Samples of pagination styling for will_paginate
+ %link{ :rel => 'stylesheet', :type => 'text/css', :href => 'pagination.css' }
+ %style{ :type => 'text/css' }
+ :sass
+ html
+ :margin 0
+ :padding 0
+ :background #999
+ :font normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif
+ body
+ :margin 2em
+ :padding 2em
+ :border 2px solid gray
+ :background white
+ :color #222
+ h1
+ :font-size 2em
+ :font-weight normal
+ :margin 0 0 1em 0
+ h2
+ :font-size 1.4em
+ :margin 1em 0 .5em 0
+ pre
+ :font-size 13px
+ :font-family Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace
-- pagination = '<span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
-- pagination_no_page_links = '<span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
+ - pagination = '<span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
+ - pagination_no_page_links = '<span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>'
-%body
- %h1 Samples of pagination styling for will_paginate
- %p
- Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
- There is a Sass version of it for all you sassy people.
- %p
- Read about good rules for pagination:
- %a{ :href => 'http://kurafire.net/log/archive/2007/06/22/pagination-101' } Pagination 101
- %p
- %em Warning:
- page links below don't lead anywhere (so don't click on them).
+ %body
+ %h1 Samples of pagination styling for will_paginate
+ %p
+ Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
+ There is a Sass version of it for all you sassy people.
+ %p
+ Read about good rules for pagination:
+ %a{ :href => 'https://gist.github.com/622561' } Pagination 101
+ %p
+ %em Warning:
+ page links below don't lead anywhere (so don't click on them).
- %h2 Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span>
- %div= pagination
+ %h2 Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span>
+ %div= pagination
- %h2 Digg.com
- .digg_pagination= pagination
+ %h2 Digg.com
+ .digg_pagination= pagination
- %h2 Digg-style, no page links
- .digg_pagination= pagination_no_page_links
- %p Code that renders this:
- %pre= '<code>%s</code>' % %[<%= will_paginate @posts, :page_links => false %>].gsub('<', '&lt;').gsub('>', '&gt;')
+ %h2 Digg-style, no page links
+ .digg_pagination= pagination_no_page_links
+ %p Code that renders this:
+ %pre= '<code>%s</code>' % %[<%= will_paginate @posts, :page_links => false %>].gsub('<', '&lt;').gsub('>', '&gt;')
- %h2 Digg-style, extra content
- .digg_pagination
- .page_info Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total
- = pagination
- %p Code that renders this:
- %pre= '<code>%s</code>' % %[<div class="digg_pagination">\n <div clas="page_info">\n <%= page_entries_info @posts %>\n </div>\n <%= will_paginate @posts, :container => false %>\n</div>].gsub('<', '&lt;').gsub('>', '&gt;')
+ %h2 Digg-style, extra content
+ .digg_pagination
+ .page_info Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total
+ = pagination
+ %p Code that renders this:
+ %pre= '<code>%s</code>' % %[<div class="digg_pagination">\n <div clas="page_info">\n <%= page_entries_info @posts %>\n </div>\n <%= will_paginate @posts, :container => false %>\n</div>].gsub('<', '&lt;').gsub('>', '&gt;')
- %h2 Apple.com store
- .apple_pagination= pagination
+ %h2 Apple.com store
+ .apple_pagination= pagination
- %h2 Flickr.com
- .flickr_pagination
- = pagination
- .page_info (118 photos)
+ %h2 Flickr.com
+ .flickr_pagination
+ = pagination
+ .page_info (118 photos)
View
157 examples/index.html
@@ -1,92 +1,71 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
-</html>
-<head>
- <title>Samples of pagination styling for will_paginate</title>
- <link href='pagination.css' rel='stylesheet' type='text/css' />
- <style type='text/css'>
- html {
- margin: 0;
- padding: 0;
- background: #999;
- font: normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif; }
-
- body {
- margin: 2em;
- padding: 2em;
- border: 2px solid gray;
- background: white;
- color: #222; }
-
- h1 {
- font-size: 2em;
- font-weight: normal;
- margin: 0 0 1em 0; }
-
- h2 {
- font-size: 1.4em;
- margin: 1em 0 .5em 0; }
-
- pre {
- font-size: 13px;
- font-family: Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace; }
- </style>
-</head>
-<body>
- <h1>Samples of pagination styling for will_paginate</h1>
- <p>
- Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
- There is a Sass version of it for all you sassy people.
- </p>
- <p>
- Read about good rules for pagination:
- <a href='http://kurafire.net/log/archive/2007/06/22/pagination-101'>Pagination 101</a>
- </p>
- <p>
- <em>Warning:</em>
- page links below don't lead anywhere (so don't click on them).
- </p>
- <h2>
- Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span>
- </h2>
- <div>
- <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- </div>
- <h2>Digg.com</h2>
- <div class='digg_pagination'>
- <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- </div>
- <h2>Digg-style, no page links</h2>
- <div class='digg_pagination'>
- <span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- </div>
- <p>Code that renders this:</p>
- <pre>
- <code>&lt;%= will_paginate @posts, :page_links =&gt; false %&gt;</code>
- </pre>
- <h2>Digg-style, extra content</h2>
- <div class='digg_pagination'>
- <div class='page_info'>
- Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total
+ <head>
+ <title>Samples of pagination styling for will_paginate</title>
+ <link href='pagination.css' rel='stylesheet' type='text/css' />
+ <style type='text/css'>
+ html {
+ margin: 0;
+ padding: 0;
+ background: #999999;
+ font: normal 76% "Lucida Grande", Verdana, Helvetica, sans-serif; }
+
+ body {
+ margin: 2em;
+ padding: 2em;
+ border: 2px solid gray;
+ background: white;
+ color: #222222; }
+
+ h1 {
+ font-size: 2em;
+ font-weight: normal;
+ margin: 0 0 1em 0; }
+
+ h2 {
+ font-size: 1.4em;
+ margin: 1em 0 0.5em 0; }
+
+ pre {
+ font-size: 13px;
+ font-family: Monaco, "DejaVu Sans Mono", "Bitstream Vera Mono", "Courier New", monospace; }
+ </style>
+ </head>
+ <body>
+ <h1>Samples of pagination styling for will_paginate</h1>
+ <p>
+ Find these styles in <b>"examples/pagination.css"</b> of <i>will_paginate</i> library.
+ There is a Sass version of it for all you sassy people.
+ </p>
+ <p>
+ Read about good rules for pagination:
+ <a href='https://gist.github.com/622561'>Pagination 101</a>
+ </p>
+ <p>
+ <em>Warning:</em>
+ page links below don't lead anywhere (so don't click on them).
+ </p>
+ <h2>Unstyled pagination <span style="font-weight:normal">(<i>ewww!</i>)</span></h2>
+ <div><span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a></div>
+ <h2>Digg.com</h2>
+ <div class='digg_pagination'><span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a></div>
+ <h2>Digg-style, no page links</h2>
+ <div class='digg_pagination'><span class="disabled prev_page">&laquo; Previous</span> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a></div>
+ <p>Code that renders this:</p>
+ <pre><code>&lt;%= will_paginate @posts, :page_links =&gt; false %&gt;</code></pre>
+ <h2>Digg-style, extra content</h2>
+ <div class='digg_pagination'>
+ <div class='page_info'>Displaying entries <b>1&nbsp;-&nbsp;6</b> of <b>180</b> in total</div>
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
+ </div>
+ <p>Code that renders this:</p>
+ <pre><code>&lt;div class="digg_pagination"&gt;&#x000A; &lt;div clas="page_info"&gt;&#x000A; &lt;%= page_entries_info @posts %&gt;&#x000A; &lt;/div&gt;&#x000A; &lt;%= will_paginate @posts, :container =&gt; false %&gt;&#x000A;&lt;/div&gt;</code></pre>
+ <h2>Apple.com store</h2>
+ <div class='apple_pagination'><span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a></div>
+ <h2>Flickr.com</h2>
+ <div class='flickr_pagination'>
+ <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
+ <div class='page_info'>(118 photos)</div>
</div>
- <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- </div>
- <p>Code that renders this:</p>
- <pre>
- <code>&lt;div class="digg_pagination"&gt;
- &lt;div clas="page_info"&gt;
- &lt;%= page_entries_info @posts %&gt;
- &lt;/div&gt;
- &lt;%= will_paginate @posts, :container =&gt; false %&gt;
- &lt;/div&gt;</code>
- </pre>
- <h2>Apple.com store</h2>
- <div class='apple_pagination'>
- <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- </div>
- <h2>Flickr.com</h2>
- <div class='flickr_pagination'>
- <span class="disabled prev_page">&laquo; Previous</span> <span class="current">1</span> <a href="./?page=2" rel="next">2</a> <a href="./?page=3">3</a> <a href="./?page=4">4</a> <a href="./?page=5">5</a> <a href="./?page=6">6</a> <a href="./?page=7">7</a> <a href="./?page=8">8</a> <a href="./?page=9">9</a> <span class="gap">&hellip;</span> <a href="./?page=29">29</a> <a href="./?page=30">30</a> <a href="./?page=2" rel="next" class="next_page">Next &raquo;</a>
- <div class='page_info'>(118 photos)</div>
- </div>
-</body>
+ </body>
+</html>
View
3  lib/will_paginate/view_helpers.rb
@@ -56,6 +56,7 @@ module ViewHelpers
# * <tt>:id</tt> -- HTML ID for the container (default: nil). Pass +true+ to have the ID
# automatically generated from the class name of objects in collection: for example, paginating
# ArticleComment models would yield an ID of "article_comments_pagination".
+ # * <tt>:remote</tt> -- sets to true the data-remote or remote attribute, depending of the inplementation of link_to
#
# Advanced options:
# * <tt>:param_name</tt> -- parameter name for page number in URLs (default: <tt>:page</tt>)
@@ -302,7 +303,7 @@ def page_link_or_span(page, span_class, text = nil)
if page and page != current_page
classnames = span_class && span_class.index(' ') && span_class.split(' ', 2).last
- page_link page, text, :rel => rel_value(page), :class => classnames
+ page_link page, text, :rel => rel_value(page), :class => classnames, :remote => @options[:remote]
else
page_span page, text, :class => span_class
end
View
6 test/view_test.rb
@@ -297,6 +297,12 @@ def test_complex_custom_page_param
end
end
+ def test_remote_links
+ paginate({}, :remote => true) do
+ assert_select 'a[remote=true]', 3
+ end
+ end
+
def test_custom_routing_page_param
@request.symbolized_path_parameters.update :controller => 'dummy', :action => nil
paginate :per_page => 2 do
Something went wrong with that request. Please try again.