我正在尝试在Grails 2.1上安装jQuery DataTable,但直到现在都没有成功。我已经安装了jQuery、jQuery-ui和jquery-datatable插件,并将以下代码添加到main.gsp文件中:
<g:javascript library="jquery" plugin="jquery" />
<r:require module="application"/>
<jqui:resources />
并将此代码添加到我的视图中:
<jqDT:resources />
<g:javascript>
$(document).ready(function() {
jQuery('#demo').dataTable({
sScrollY: '70%',
bProcessing: true,
bServerSide: true,
sAjaxSource: '${request.contextPath + '/person/dataTablesData'}' ,
sPaginationType: "full_numbers",
aLengthMenu: [[100, 500, 1000, 5000, -1], [100, 500, 1000, 5000, "All"]],
iDisplayLength: 500
});
});
</g:javascript>
但是当我尝试渲染它时,出现了以下异常:
TypeError: jQuery(...).dataTable is not a function
我该怎样解决这个问题?
sAjaxSource
不应该是类似于 sAjaxSource: '${request.contextPath}'+'/person/dataTablesData' 这样的东西吗? - Daniel