Comments (3)
https://github.com/delef/will_paginate-bootstrap4
from will_paginate-bootstrap.
You can create pagination_helper.rb in you_app/assets/helpers/
require "will_paginate/view_helpers/action_view"
module PaginationHelper
module BootstrapRenderer
def to_html
html = pagination.map do |item|
item.is_a?(Fixnum) ?
page_number(item) :
send(item)
end.join(@options[:link_separator])
html = html_container(html) if @options[:container]
tag("nav", tag("ul", html, class: @options[:class]))
end
protected
def page_item(text, url, link_status = nil)
text = text.to_s + tag(:span, "(current)", class: "sr-only") if link_status == "active"
link_tag = link_status.nil? ? link(text, url, class: "page-link", rel: text) : tag(:span, text, class: "page-link")
tag(:li, link_tag, class: "page-item #{link_status}")
end
def page_number(page)
link_status = "active" if page == current_page
page_item(page, page, link_status)
end
def gap
text = @template.will_paginate_translate(:page_gap) { '…' }
page_item(text, nil, "disabled")
end
def previous_page
num = @collection.current_page > 1 && @collection.current_page - 1
previous_or_next_page(num, @options[:previous_label], "Previous")
end
def next_page
num = @collection.current_page < total_pages && @collection.current_page + 1
previous_or_next_page(num, @options[:next_label], "Next")
end
def previous_or_next_page(page, text, aria_label)
link_status = "disabled" unless page
page_item(text, page, link_status)
end
end
end
WillPaginate::ActionView::LinkRenderer.send :include, PaginationHelper::BootstrapRenderer
from will_paginate-bootstrap.
@delef you've just saved my day, thank you!
from will_paginate-bootstrap.
Related Issues (20)
- License missing from gemspec HOT 2
- Is it possible to remove the default class of `.pagination`? HOT 6
- Responsive pagination HOT 1
- Move to central organisation? HOT 13
- Pagination class on div not ul HOT 2
- Mongoid Support HOT 2
- Anyway to change the size of the pagination? HOT 1
- Error: Uninitialized Constant HOT 2
- Supporting Screen Readers HOT 1
- Add padrino support HOT 2
- Is there a plan to add a drop-down for results per page next to the page selection section?
- Class pagination on div rather than ul HOT 1
- Using more bootstrap pagination classes HOT 1
- i18n support? HOT 2
- Size control? HOT 1
- Limiting number of pages in links using will_paginate HOT 1
- Ruby 2.4 Deprecation Warnings
- Mathjax content not rendering HOT 1
- Deprecated Fixnum on Ruby v2.4.0+ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from will_paginate-bootstrap.