Come includere jQuery.js in Grails?
-
12-11-2019 - |
Domanda
Ho un progetto Grails 2.0.0 che è stato creato utilizzando grails create-app
. Nei miei file HTML e GSP, sto cercando di includere jquery.js
. Ho provato tutto quanto segue senza successo:
<script type="text/javascript" src="jquery/jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery/jquery.js"></script>
<g:javascript library="jquery"/>
I primi due <script>
I tag risultano in 404 non trovati (verificati con Firebug). Il <g:javascript>
Il tag risulta in nulla incluso (verificato usando la sorgente di visualizzazione).
Nella home page della mia applicazione Grails, indica che JQuery 1.7.1 è installato (sotto "plugin installati").
Qual è il modo corretto in Grails per includere il file jQuery .js?
Seguito: Il file .gsp:
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>Test</title>
<g:javascript library="jquery/jquery"/>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Risultati nella fonte HTML Follow:
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Nota la mancanza di jQuery.js incluso.
Follow-up 2:
Sto creando la mia app usando grails create-app
:
13:56:40 ~/grailsDev $ grails create-app helloworld
| Created Grails Application at /Users/steve/grailsDev/helloworld
13:56:57 ~/grailsDev $ cd helloworld/
13:57:06 ~/grailsDev/helloworld $ ls -al web-app/js
total 8
drwxr-xr-x 3 steve staff 102 Jan 21 13:56 .
drwxr-xr-x 7 steve staff 238 Dec 15 08:04 ..
-rw-r--r-- 1 steve staff 183 Dec 14 22:56 application.js
13:57:23 ~/grailsDev/helloworld $ grails -version
Grails version: 2.0.0
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow