开发者

I want to include everything from my main page except one js file ..

I have a use case in which i want to include my main.gsp file in my page list.gsp , that is easily achieved by doi开发者_如何学Cng

<meta name="layout" content="main"/>

But the problem is that it has jQuery 1.6 version but i want an alternative to that a file called as jquery.js and i when i am including it as well in addition to the main layout its conflicting and creating a problem .. like

<script type="text/javascript" src="${resource(dir: 'js/jquery', file: 'jquery.js')}"></script>

The above is not working , so what i have thought is either manually differentiate the files to be included on my list.gsp page or is there a way to include everything that is on main.gsp page except this jQuery1.6.js file ??

I am open to any other suggestions.. Thanks in advance


A dirty method could be to put the script import in a if block that checks for a page property, and in your list.gsp set that property.

In list.gsp:

<body fooProperty="1">

And in main.gsp:

<g:if test="${pageProperty(name:'body.fooProperty) ?: false}">
<%--includes you want for list.gsp here--%>
</g:if>
<g:else>
<%--normal script link -%>
</g:else>

Forces a if/else on every single page load you got, but there isnt many other ways to do it. Might be to set a hidden page property and write a loader that overrides the 1.6 import in javascript itself.


Put in your main.gsp

${if(!params.jqueryVersion) params.jqueryVersion=''}
<script type="text/javascript" src="${resource(dir: 'js/jquery', file: 'jquery${params.jqueryVersion)}.js')}"></script>

and in your list controller return

[myInstancesList:list, jqueryVersion:'-1.4.2']
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜