Skip to content Skip to sidebar Skip to footer

Grails Link - Add Javascript Variable Into Params

$('#andiebox').append('Psychos in HH

Solution 1:

<g:link is server-side tag, so it could only prepare base to your link. All client side parameters should be filled on client side. Something like:

var params = { 
   what: '${what.encodeAsJavaScript()}', //as I understand all this variables are server side variables
   sort: '${sort.encodeAsJavaScript()}', 
   type: '${type.encodeAsJavaScript()}', 
   distance: '${distance.encodeAsJavaScript()}' 
}; 
params.destination =  $(this).attr("id");
var urlBase = '${createLink(controller:"search", action: "search").encodeAsJavaScript()}';

$('#andiebox').append('<a href="' + url + '?' + $.serialize(params) + '">Psychos in HH</a>');

Post a Comment for "Grails Link - Add Javascript Variable Into Params"