我正在使用 x-editable 在弹出窗口中填充选择列表。现在我想将我的密钥发送到服务器,我的代码是这样的
<a href="#" id="status" data-type="select" data-pk="1" data-url="${g.createLink(controller: 'someController', action: 'someAction')}" data-title="Select CV" class="btn btn-primary">
<image src="${resource(dir: 'images/template', file: 'logo11.png')}"/> ${session.someList?.size()} CV(s) Created
</a>
<script>
$(function () {
$('#status').editable({
value: 1,
source: [
<g:each in="${session.someList}" var="xyz" status="idx">
{value: ${xyz?.id}, text: "${xyz.title}", srsSelected: ${xyz.id}, updateXyz: "updateXyz"},
</g:each>
]
});
});
</script>
我想将我的 srsSelected 密钥发送到服务器,我做了谷歌但没有得到重点......
编辑:
现在我可以使用(经过长时间的研究)将我的密钥发送到服务器
params: function (params) { //params already contain `name`, `value` and `pk`
var data = {};
data['cvSelected'] = params.pk;
return data;
}
因此我更新的代码是:
<a href="#" id="status" data-type="select" data-pk="1" data-url="${g.createLink(controller: 'someController', action: 'someAction')}" data-title="Select CV" class="btn btn-primary">
<image src="${resource(dir: 'images/template', file: 'logo11.png')}"/>
${session.someList?.size()} CV(s) Created
</a>
<script>
$(function () {
$('#status').editable({
value: 1,
source: [
<g:each in="${session.someList}" var="xyz" status="idx">
{value: ${xyz?.id}, text: "${xyz.title}", srsSelected: ${xyz.id}, updateXyz: "updateXyz"},
</g:each>
],
params: function (params) { //params already contain `name`, `value` and `pk`
var data = {};
data['srsSelected'] = params.pk;
return data;
}
});
});
</script>
我能够发送pk
insrsSelected
键的值,但这次我需要srsSelected
动态设置值。