jquery - grails 2.4.4 jQuery datepicker

标签 jquery grails datepicker

我无法在我的Grails 2.4.4应用程序中使JQuery Datepicker正常工作。
无论是否带有jquery-UI插件,它都会失败。因为UI组件使用的是jquery 1.11,所以UI组件不是集成在最新的jquery插件中吗?如何添加日期选择器?

我有以下代码:

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')}"/>

最佳答案

您必须在插件部分下取消注释jquery-ui插件
并将下一行添加到您的application.js

//= require js/jquery-ui-1.10.4.custom.min

也许您想在appliaction.css中加入默认主题
*= require themes/ui-lightness/jquery-ui-1.10.4.custom.min

我希望这有帮助。

关于jquery - grails 2.4.4 jQuery datepicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29139703/

相关文章:

javascript - 按右箭头键时光标消失

unit-testing - 由于错误,无法测试我的 grails 应用程序

java - Grails发送文件然后删除

php - 无法将日期选择器日期插入mysql

jquery - 如何使用 Jquery UI+Laravel 传递日期值

javascript - 如何在 INPUT FIELD 而不是 SPAN 中将变量显示为总计?

javascript - 将 javascript 函数作为 data-* 属性传递并执行

jquery - 使用 DOMSubtreeModified 突变事件。在 jQuery 中

grails - Grails 2应用程序的初始数据加载

javascript - Pickadate:将日期转换为unix时间戳