How to include jquery.js in Grails?

后端 未结 10 2147
北海茫月
北海茫月 2021-02-05 06:50

I have a Grails 2.0.0 project that was created using grails create-app. In my HTML and GSP files, I\'m trying to include jquery.js. I\'ve tried all of

10条回答
  •  鱼传尺愫
    2021-02-05 07:18

    As per the current docs - http://grails.org/plugin/jquery (Grails version: 1.3 > *) on 18th Sept, 2015


    Installation

    To install the jQuery plugin type this command from your project's root folder:

    grails install-plugin jquery
    

    Targets:

    grails installJQuery
    
    • This target downloads and installs jquery-1.4.2.js and jquery-1.4.2.min.js under web-app/js/jquery/

    The complete jQuery distribution is downloaded and installed under your project's /web-app/js/jQuery folder.


    Usage

    Ajax via jQuery

    To have the Grails' adaptive AJAX support adapt itself to jQuery (rather than the default of Prototype, or another choice like YUI or Dojo):

    Since Grails 1.2:

    Add this line to your layout-file

    
    

    and the following to your grails-app/conf/config.groovy

    grails.views.javascript.library="jquery"
    

    alternatively you can use:

    
    

    (without plugin="jquery") but you will need to call the grails installJQuery target (see Installation Tab)

提交回复
热议问题