$('#andiebox').append('<g:link controller="search" action="search" params="[where:'+destination+', what:what, sort:sort, type:type, distance:distance]">Psychos in HH</g:link>');
grails不接受这个,我怎样才能正确插入变量?
变量是来自输入的客户端红外线:
var destination = $(this).attr("id");
var metaSection = $("#metaSection").val();
答案 0 :(得分:4)
<g:link
是服务器端标记,因此它只能为您的链接做准备。应在客户端填写所有客户端参数。类似的东西:
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>');