以下是代码片段:
<li>
<g:link controller="Customer" action="customerInfo" id="${CustomerInstance.id}" onclick="return confirm('${message(code: 'default.button.customerInfo.confirm.message', default: 'Customer Info' ,args:['${CustomerInstance.id}'])}');">Customer Information</g:link>
</li>
代码的作用是每当用户点击链接时,警报框应附带客户ID。
此代码适用于我:
<li>
<g:link controller="Customer" action="customerInfo" id="${CustomerInstance.id}" onclick="return confirm(Customer ID '+${CustomerInstance.id}+'.Are you sure to continue? ');">Customer Information</g:link>
</li>
我认为引号有问题。有人可以帮帮我吗?
答案 0 :(得分:0)
请勿在'args'参数中使用单引号或GSP表达式。您可以执行以下操作:args:[CustomerInstance.id]
完整示例:
<li>
<g:link controller="Customer" action="customerInfo" id="${CustomerInstance.id}" onclick="return confirm('${message(code: 'default.button.customerInfo.confirm.message', default: 'Customer Info' ,args:[CustomerInstance.id])}');">Customer Information</g:link>
</li>