将 Groovy Server Pages 的实例属性传递给 javascript 函数
以下是代码片段:
<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>
我认为引号有问题。有人可以帮我吗?
Here is the snippet of code:
<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>
What the code does is whenever a user clicks the link, an alert box should come with the customer id.
This code works for me:
<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>
I think there is something wrong with the quotes.Can somebody help me out??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要在“args”参数中使用单引号或 GSP 表达式。您可以执行以下操作: args:[CustomerInstance.id]
完整示例:
Don't use the single quotes or GSP expression in your 'args' parameter. You can just do the following: args:[CustomerInstance.id]
Full example: