Grails+Jquery-ui - integration issue?

醉酒当歌 提交于 2019-12-08 08:03:30

Are you using the Resource framework? If yes, you should use the jquery-ui module like this:

<r:require module="jquery-ui"/>

Documentation on jquery-ui and resource framework.

Note - I incorrectly edited my original question along with providing the answer, the original question also has the solution description.

I finally was successful integrating jquery-ui and grails, faced some issue which allow the solution to runs. Steps.

  1. Create new Grails project (my environment grails 2.2.0, JDK 7, GGTS latest version)
  2. Install jquery-ui plug-in, edit BuildConfig add runtime ":jquery-ui:1.8.24".
  3. Create a controller and gsp page, using grails

GSP Page content

 <html>
    <head>

    <title>Simple GSP page</title>
    <g:javascript library="jquery" />
    <g:javascript library="jquery-ui"/>

    <r:layoutResources/>   

    <script type="text/javascript">

       $(document).ready(function() { 
           $("#datepicker").datepicker({dateFormat: 'yy/mm/dd'}); }) 
    </script>


     </head>
        <body>
            <div>
                <p> Between <input type="text" id="datepicker"> </p>        
            </div>
          <r:layoutResources/>
        </body>
    </html>

Controller code:

    def testDatePicker = { 
    }

4. Run the solution in grails, navigate to the date picker on your page, it should show you the sleek date picker

Piyush Chaudhari

You need to add following line for plugin.

plugins {    
        runtime ":jquery:1.8.3"
        compile ":jquery-ui:1.8.24"
    }

And add the following line on which gsp page you use Jquery UI.

< head>
     < g:javascript library="jquery" />
     < r:require modules="jquery-ui"/>
     < r:script>
        $(document).ready(function() {
               your code...
        });
     < /r:script>
< /head>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!