我想在gsp中的不同ID上触发相同的对话框。
所以这是代码:
<div class="yui3-widget-bd">
<g:each in="deployments" status="index" var="workflow">
<% def id = "reloadFile"+index %>
<gui:dialog title="Reload File" form="true" modal="true"
controller="admin" action="reloadFile"
triggers="[show:[id:'${id}', on:'click']]">
<p>To reload the file, please...</p><br />
<input type="file" id="deploymentFile" name="deploymentFile" />
</gui:dialog>
</g:each>
</div>
问题是scriptlet代码:
triggers="[show:[id:'<%=id %>', on:'click']]"
没有得到评估。
侦听生成的html源中的事件的Javascript部分如下所示:
YAHOO.util.Event.addListener("${id}", "click", GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce.show, GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce, true);
那么我该如何管理源看起来像这样呢? :
YAHOO.util.Event.addListener("reloadFile1", "click", GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce.show, GRAILSUI.gui_e0100d149e0a7b531017e0decaee9fce, true);
谢谢。
最佳答案
与jsps相同:
<%def something = true%>
<%=什么? “这是一个事实陈述”:“这是错误的”%>
请注意,这可能是代码异味,并且代码应在99.9%的情况下属于域, Controller 或taglib。
Here's the reference documentation for more info.
关于grails - 在标记的属性内使用scriptlet或EL(Grails UI插件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10331196/