bootstrap 与 rails 2.3.8整合之:will_paginate插件的使用
来源:互联网 发布:迈腾轮毂尺寸数据 编辑:程序博客网 时间:2024/06/11 22:22
新增render, application_helper.erb
view层如下引用
还必须增加如下css才完美
class BootstrapLinkRenderer < ::WillPaginate::LinkRenderer def initialize #@gap_marker = @template.content_tag :li, @template.content_tag(:link(super, '#')), :class => 'disabled' @gap_marker = '<li class="disabled"><a href="javascript:void(0)">…</a></span>' end def to_html links = @options[:page_links] ? windowed_links : [] links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label]) links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label]) html = links.join(@options[:separator]) html = html.html_safe if html.respond_to? :html_safe @options[:container] ? @template.content_tag(:ul, html, html_attributes) : html end def page_link(page, text, attributes = {}) @template.content_tag(:li, @template.link_to(text, url_for(page)), attributes) end def page_span(page, text, attributes = {}) @template.content_tag(:li,@template.link_to(text,"javascript:void(0)"), attributes) endend
view层如下引用
<%=will_paginate @videos, {:renderer => BootstrapLinkRenderer,:previous_label => "上一页", :next_label => "下一页"} %>
还必须增加如下css才完美
<style type="text/css"> .pagination .current a, .pagination .current a:hover{ background-color: transparent; color: #999999; cursor: default; } </style>
rails 3.0 以上,请参考:
http://www.leonardteo.com/2011/12/rails-bootstrap-and-will_paginate/
will_paginate.zh.yml will pageinate 的中文化
zh: will_paginate: models: entry: 资源 previous_label: "← 前一页" next_label: "下一页 →" page_gap: "... ..." page_entries_info: single_page: zero: "没有发现 %{model} " one: "显示 1 %{model}" other: "显示所有 %{count} %{model}" single_page_html: zero: "没有发现 %{model} " one: "显示 <b>1</b> %{model}" other: "显示 <b>所有 %{count}</b> %{model}" multi_page: "显示 %{model} %{from} - %{to} 共 %{count} 所有记录" multi_page_html: "显示 %{model} <b>%{from} - %{to}</b> 共 <b>%{count}</b> 所有记录"
没有发现 entries 的问题解决总算比较圆满的结局了该问题,增加了 models: entry 资源
defaults = ["models.#{model_key}"] defaults << Proc.new { |_, opts| if model.respond_to? :model_name model.model_name.human(:count => opts[:count]) else name = model_key.to_s.tr('_', ' ') raise "can't pluralize model name: #{model.inspect}" unless name.respond_to? :pluralize opts[:count] == 1 ? name : name.pluralize end } model_name = will_paginate_translate defaults, :count => model_countwill_paginate_translate 的方法定义如下def will_paginate_translate(keys, options = {}) if defined? ::I18n defaults = Array(keys).dup defaults << Proc.new if block_given? ::I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => :will_paginate)) else key = Array === keys ? keys.first : keys yield key, options end end
- bootstrap 与 rails 2.3.8整合之:will_paginate插件的使用
- rails中will_paginate插件,当前页的使用
- Rails使用will_paginate插件进行分页
- rails 中will_paginate-bootstrap做分页
- Rails分页plugin之will_paginate
- rails + bootstrap 做项目使用的一些插件
- rails + bootstrap 做项目使用的一些插件
- 如何向Ruby on Rails 分页插件 will_paginate 的链接插入其它参数
- rails 分页 will_paginate 的相关用法
- Rails2中使用will_paginate插件进行分页
- Rails2中使用will_paginate插件实现分页
- rails will_paginate ajax
- rails中使用will_paginate针对数组进行分页处理
- Rails中Bootstrap的安装和使用
- Rails中Bootstrap的安装和使用
- BootStrap插件使用之模态框
- BootStrap之datetimepicker插件使用
- rails插件ajax_scaffold的使用
- Oracle APEX系列(一) 安装
- 在Red Hat Linux 5.1.19.6上安装Oracle10.2.0.1
- 第十六周实验报告1
- 国内首个HTML5应用开发平台AppCan开启限量内测
- XP系统中如何查哪些网址曾经远程连接过本机器。
- bootstrap 与 rails 2.3.8整合之:will_paginate插件的使用
- 转帖 3DEX加密
- 国内外著名开源b2c电子商务系统比较包括asp.net和php
- 解决Ext.form.TextField的 maxLength 属性失效问题
- android开发步骤
- SQL注入常用函数
- Linux中scp命令用法
- 第十六周实验报告2
- 注入过程中的中文处理方法