【发布时间】:2015-03-19 08:12:58
【问题描述】:
我无法让 JQuery Datepicker 在我的 Grails 2.4.4 应用程序中工作。 无论有没有 jquery-UI 插件,它都会失败。最新的jquery插件中集成的UI组件不是这样吗,因为它使用的是jquery 1.11?如何添加日期选择器?
我有这个代码:
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"
应用程序.js
//= require jquery
//= require_tree .
//= require_self
if (typeof jQuery !== 'undefined') {
(function($) {
$('#spinner').ajaxStart(function() {
$(this).fadeIn();
}).ajaxStop(function() {
$(this).fadeOut();
});
})(jQuery);
}
创建.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')}"/>
【问题讨论】:
标签: jquery grails datepicker