2015-03-19 4 views
0

Мне не удается получить JQuery Datepicker, работающий в моем приложении Grails 2.4.4. С плагином jquery-UI или без него он не работает. Разве это не тот случай, когда компоненты пользовательского интерфейса интегрированы в последний плагин jquery, поскольку это jQuery 1.11? Как добавить датупиксера?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')}"/> 

ответ

0

Вы должны раскомментировать 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 

Я надеюсь, что это помогает.

+0

Нет сожаления. Я получаю эту ошибку в chrome: 'Uncaught TypeError: undefined не является функцией' в этой строке: ' $ ("# install"). Datepicker ({dateFormat: 'yyyy/mm/dd'}); ' – BioBier

+0

@ BioBer, вы включаете свои приложения.js и application.css в основной макет? –

Смежные вопросы