0
$('#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(); 
4

1 回答 1

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>');
于 2013-03-18T14:52:55.427 回答