Grails项目与JQuery无插件 [英] Grails project with JQuery without Plugin
问题描述
我试图建立一个简单的使用JQuery的Grails 2.1.1应用程序我有一个名为TestController的Controller和一个正确的index.gsp 。
我手动添加JQuery库,我没有使用Grails插件。我把jquery-ui-1.8.24.custom.min.js和jquery-1.8.0.min.js放在web-app / js中(位置是正确的,因为当我看到Jquery的代码时在浏览器中浏览我自己的代码并点击引用链接)
<!DOCTYPE html>
< html>
< head>
< script src =../ js / jquery-ui-1.8.24.custom.min.jstype =javascript/>
< script src =../ js / jquery-1.8.0.min.jstype =javascript/>
< script>
$(document).ready(function(){
var availableTags = [
ActionScript,
AppleScript,
Asp,
BASIC,
C,
C ++,
Clojure,
COBOL,
ColdFusion,
Erlang,
Fortran,
Groovy,
Haskell,
Java,
JavaScript,
Lisp ,
Perl,
PHP,
Python,
Ruby,
Scala,
Scheme
$;
$(#tags)。autocomplete({
source:availableTags
});
});
< / script>
< / head>
< body>
< div class =demo>
< div class =ui-widget>
< label for =tags>标记:< / label>
< input id =tags>
< / div>
< / div><! - 结束演示 - >
自动填充不起作用远。我错过了什么?
为什么不使用对资源目录的引用?
< script type =text / javascriptsrc =$ {resource(dir:'js',file:'的jquery-1.8.0.min.js')}< /脚本>
I am trying to set up a simple Grails 2.1.1 application that will use JQuery
I have one Controller called "TestController" and a rightly located index.gsp. I add the JQuery libraries manually, I am not using the Grails Plugin. I put "jquery-ui-1.8.24.custom.min.js" and "jquery-1.8.0.min.js" in web-app/js (the location is correct since I can see the code of Jquery when I browse the my own code in the browser and click the reference link)
I want to run the Autocomplete sample of JQuery. The code looks like this:
<!DOCTYPE html>
<html>
<head>
<script src="../js/jquery-ui-1.8.24.custom.min.js" type="javascript"/>
<script src="../js/jquery-1.8.0.min.js" type="javascript"/>
<script>
$(document).ready(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#tags").autocomplete({
source:availableTags
});
});
</script>
</head>
<body>
<div class="demo">
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</div><!-- End demo -->
The Autocomplete does not work so far. What am I missing?
why not use references to the resources dir?
<script type="text/javascript" src="${resource(dir:'js',file:'jquery-1.8.0.min.js')}"</script>
<script type="text/javascript" src="${resource(dir:'js',file:'jquery-ui-1.8.24.custom.min.js')}"> </script>
这篇关于Grails项目与JQuery无插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!