【问题标题】:Alphabetical paginate gem error按字母顺序分页宝石错误
【发布时间】:2014-12-15 09:46:45
【问题描述】:

我已在我的字典 rails 应用程序 (https://github.com/lingz/alphabetical_paginate) 上部署了 alphabetical_paginate gem。除了当我单击一个字母时它会卡在加载轮上并且在我刷新页面之前不会分页这一事实之外,gem 的工作原理。

我只能假设这是 gem 内部的 javascript 问题,而不是我实现它的方式?

控制器:

class WordsController < ApplicationController

  def index
    @words, @alphaParams = Word.all.alpha_paginate(params[:letter], {:default_field => "all"}){|word| word.word}
  end

查看:

<%= alphabetical_paginate @alphaParams %>

<table>
  <thead>
    <tr>
      <th>Word</th>
      <th>Wordtype</th>
      <th>Description</th>
      <th colspan="3"></th>
    </tr>
  </thead>

<div id="pagination_table">
  <tbody>
    <% @words.each do |word| %>
      <tr>
        <td><%= word.word %></td>
        <td><%= word.wordtype %></td>
        <td><%= word.description %></td>
        <td><%= link_to 'Show', word %></td>
      </tr>
    <% end %>
  </tbody>
</div>
</table>

【问题讨论】:

  • 在发帖时尽量提高好奇心,你有什么解决问题的方法?
  • 查看服务器和浏览器日志,可能有错误信息

标签: javascript ruby-on-rails ruby pagination


【解决方案1】:

你应该把你的电话改成:

@words, @alphaParams = Word.all.alpha_paginate(params[:letter], {:default_field => "all", :js => false}){|word| word.word}

alphabetical_paginate 在 js: true 时使用 ajax 功能,这将导致页面重新加载并显示正确的结果。我也不认为你可以拥有

<div id="pagination_table"> 

在桌子中间。

【讨论】:

    猜你喜欢
    • 2010-10-07
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    相关资源
    最近更新 更多