首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在我使用搜索之前,Rails数据表不起作用

在我使用搜索之前,Rails数据表不起作用
EN

Stack Overflow用户
提问于 2015-12-05 12:43:37
回答 1查看 99关注 0票数 0

您好,我试着使用DataTable gem,我已经安装了datatables和jquery ui:

代码语言:javascript
运行
复制
gem 'jquery-datatables-rails', '~> 3.3.0'
gem 'jquery-ui-rails'

并将它们添加到我的应用程序清单中: application.js.coffee:

代码语言:javascript
运行
复制
#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require bootstrap-sprockets
#= require jquery-ui
#= require dataTables/jquery.dataTables
#= require_tree .

application.scss:

代码语言:javascript
运行
复制
 *= require_self
 *= require font-awesome
 *= require jquery-ui
 *= require dataTables/jquery.dataTables
 *= require_tree .
 */

我的payments.coffee

代码语言:javascript
运行
复制
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

jQuery ->
  $('#student_payments').dataTable()

和实际表格:

代码语言:javascript
运行
复制
%table.table.table-condensed#student_payments
  %thead
    %tr
      %th= t('student.columns.first_name')
      %th= t('student.columns.last_name')
      %th= "January"
      %th= "February"
      %th= "March"
      %th= "April"
      %th= "May"
      %th= "June"
      %th= "July"
      %th= "August"
      %th= "September"
      %th= "October"
      %th= "November"
      %th= "December"
  %tbody
    - @students.each do |obj|
      %tr
        %td= obj.first_name
        %td= obj.last_name
        - @months.each do |month|
          %td 
            - if month.detect { |date| date[:student_id] == obj.id }
              - payment = month.detect { |date| date[:student_id] == obj.id }
              = payment[:date]
            - else
              no

奇怪的是,直到我搜索任何东西,它才能工作,我不能对列进行排序,分页不会被处理,但是当我搜索任何东西时,数据表就活了:D,表是分页的,我可以对列进行排序。

知道为什么吗?

EN

回答 1

Stack Overflow用户

发布于 2015-12-06 03:31:53

问题出在资产上,我对它们进行了更改,现在它工作得很好:)

application.js.coffee:

代码语言:javascript
运行
复制
#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require bootstrap-sprockets
#= require dataTables/jquery.dataTables
#= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
#= require_tree .

application.scss:

代码语言:javascript
运行
复制
 *= require_self
 *= require font-awesome
 *= require jquery-ui
 *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
 *= require_tree .
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34101369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档