0
我無法設法讓我的Grails 2.4.4應用程序中的JQuery Datepicker工作。不管有沒有jQuery UI插件,它都會失敗。是不是因爲它使用jquery 1.11將UI組件集成到最新的jquery插件中?如何添加日期選擇器?grails 2.4.4 jquery datepicker
我有這樣的代碼:
BuildConfig.groovy:
...
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:2.1.3"
compile ":mail:1.0.7"
build ':tomcat:7.0.54'
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
runtime ":jquery:1.11.1"
//compile ":jquery-ui:1.10.4"
的application.js
//= require jquery
//= require_tree .
//= require_self
if (typeof jQuery !== 'undefined') {
(function($) {
$('#spinner').ajaxStart(function() {
$(this).fadeIn();
}).ajaxStop(function() {
$(this).fadeOut();
});
})(jQuery);
}
create.gsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<title>Create</title>
</head>
<body>
<g:javascript library="jquery" plugin="jquery"/>
<%-- <jq:resource bundle="ui" components="datepicker" /> Gives a nullpointer exception!!!--%>
<script type="text/javascript">
$(document).ready(function()
{
$("#install").datepicker({dateFormat: 'yyyy/mm/dd'});
})
</script>
<div class="body">
...
<input name="install" id="install" value="${fieldValue(bean:blaBlubInstance,field:'install')}"/>
沒有抱歉。我在chrome中得到這個錯誤:'未捕獲的TypeError:undefined不是函數' at this line: '$(「#install」)。datepicker({dateFormat:'yyyy/mm/dd'});' – BioBier 2015-03-23 14:06:02
@ BioBer,你是否將你的application.js和application.css包含在主佈局中? – 2015-03-24 14:52:28