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??
Don't use the single quotes or GSP expression in your 'args' parameter. You can just do the following: args:[CustomerInstance.id]
Full example:
<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>