How To Use G:message From Javascript
There are some messages coming from a Javascript file to a GSP page. How can I implement g:message in a Javascript page? For example: if ($('#name').val() == '') { $('#nameStat
Solution 1:
Try this kind of syntax :
function foo() {
return "${message(code:'my.message.code')}";
}
Solution 2:
If I understand correctly, you want to be able to use the output from g:message in your javascript.
There is a very helpful blog post which talks about how to use g:createLink in a similar way that you want, so you can easily adapt it to use g:message as well. Check out the post here, there is some useful info in the comments as well.
The idea is to create javascript objects in your GSP file; which should be defined before including your javascript file; and then just access those global objects in your js code.
Edit:
You might also be interested in the GSParse Plugin. I haven't tried it my self but I think it accomplishes what you are looking for as well.
Post a Comment for "How To Use G:message From Javascript"