您好,我试着使用DataTable gem,我已经安装了datatables和jquery ui:
gem 'jquery-datatables-rails', '~> 3.3.0'
gem 'jquery-ui-rails'
并将它们添加到我的应用程序清单中: application.js.coffee:
#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require bootstrap-sprockets
#= require jquery-ui
#= require dataTables/jquery.dataTables
#= require_tree .
application.scss:
*= require_self
*= require font-awesome
*= require jquery-ui
*= require dataTables/jquery.dataTables
*= require_tree .
*/
我的payments.coffee
# 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()
和实际表格:
%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,表是分页的,我可以对列进行排序。
知道为什么吗?
发布于 2015-12-06 03:31:53
问题出在资产上,我对它们进行了更改,现在它工作得很好:)
application.js.coffee:
#= 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:
*= require_self
*= require font-awesome
*= require jquery-ui
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
*= require_tree .
https://stackoverflow.com/questions/34101369
复制相似问题