嵌套引号:actionsubmit标记内的javascript片段内的消息标记

时间:2012-03-26 20:33:16

标签: grails gsp

我有一个提交按钮,我想要一个确认弹出窗口,这样做很好:

<g:actionSubmit value="Delete" 
action="deleteTpsReport" 
onclick="return confirm('ohnoes!');"

但是当我想将确认文本移到messages.properties文件中时,我尝试:

<g:actionSubmit value="Delete" 
action="deleteTpsReport" 
onclick="return confirm('<g:message code="tps.delete.confirmation"/>');"

不起作用,');"显示在页面上,javascript完全被忽略。

有没有办法嵌套这些代码,以便我可以在message的事件处理程序中使用actionSubmit

2 个答案:

答案 0 :(得分:5)

这应该有效:

<g:actionSubmit value="Delete" 
action="deleteTpsReport" 
onclick="return confirm('${message(code: 'tps.delete.confirmation')}');"/>

答案 1 :(得分:0)

您可以尝试使用等效的HTML实体转义内部双引号,或使用单引号的HTML实体转义:

onclick="return confirm('<g:message code=&quot;tps.delete.confirmation&quot;/>');"

onclick="return confirm('<g:message code=&#039;tps.delete.confirmation&#039;/>');"
相关问题