【发布时间】:2013-01-14 23:11:54
【问题描述】:
我正在尝试在带有 jquery 插件 v1.8.0 的 grails 2.1.1 应用程序中使用 jquery。
我的 .js 文件在 'web-app/js/' 中
我的视图标题是
<head>
<g:javascript library="jquery" plugin="jquery"/>
<g:javascript src="dataFeed.js"/>
这行得通:
alert("hello");
这不是:
$(document).ready(function(){
alert("help");
});
有什么想法吗?
【问题讨论】:
-
控制台中有什么东西吗?
$(function() { alert("ohai"); })呢? -
$(function() { alert("ohai"); }) 不起作用。
[17:34:19.430] GET http://localhost:8080/turingpages/factorize [HTTP/1.1 200 OK 106ms] [17:34:19.567] GET http://localhost:8080/turingpages/js/dataFeed.js [HTTP/1.1 302 Found 3ms] [17:34:19.585] GET http://localhost:8080/turingpages/static/js/dataFeed.js [HTTP/1.1 200 OK 2ms] -
代替
<g:javascript />,试试<r:require module="jquery" />