Problem with :inner_window and :outer_window
-
biscazziere
- Assigned user changed from Chris Wanstrath to Mislav
I'm not sure if I get correctly ho to use those settings, but it seems to me that in version 2.3.2 they don't work as expected:
I do in the view: <%= will_paginate @articles, :inner_window => 2, :outer_window => 0 %>
Then I have 8 pages: I go to page 1 and I see: 1 2 3 4 5 ... 8 Next >
If I go to page 4, I see: < Previous 1 2 3 4 5 6 7 8 Next >
On page 7 I see: < Previous 1 ... 4 5 6 7 8 Next >
if :inner_windows represent the number of page links I see around the current page, it seems to work bad.
-
Mislav
- State changed from new to invalid
Hey, your observation is correct, but this is not a bug. It's just some undocumented behavior.
When you go to page N with :inner_window being 2, the visible pages around it should be:
... N-2 N-1 N N+1 N+2 ...But when the page N is first or last, we have a problem. Watch what pages would be visible if we're on the first page:
-1 0 1 2 3 ...Oops, pages "-1" and "0" don't exist. They are out of bounds. So what will_paginate does is that it takes visible pages out of bounds on the left and adds them to visible pages on the right (and vice-versa).
This means that page 1 has, instead of 2 numbers on the left and 2 on the right, 0 numbers on the left and 4 on the right.
This behavior ensures that rendered page links will always be roughly the same width.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.