Reputation: 1084
$('#andiebox').append('<g:link controller="search" action="search" params="[where:'+destination+', what:what, sort:sort, type:type, distance:distance]">Psychos in HH</g:link>');
this is not accepted by grails, how can i insert the variable correctly?
the variable is clientside generared from a input:
var destination = $(this).attr("id");
var metaSection = $("#metaSection").val();
Upvotes: 0
Views: 2157
Reputation: 35961
<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>');
Upvotes: 4