从combobox onChange事件传递两个参数 [英] Passing two parameters from combobox onChange event
问题描述
我有以下代码:
<g:select name="availableUser.id" from="${availableUsers}"
noSelection="['': message(code: 'global.noSelection')]"
optionKey="id" value="${name}"
onchange="${remoteFunction(
controller: 'report',
action: 'getAvailableUsers',
params: [report: reportInstance.id, user: this.value],
update: 'userSelection'
)}">
在远程函数getAvailableUser中我可以访问名为report的传递参数,但另一个null即使combobox正确呈现。像这样:
In remote function getAvailableUser I can access passed parameter named report but the other one(user) is constantly returning null even though combobox is properly rendered. Like this:
...
<option value="21">John Smith</option>
...
我试图获取所选的值项目。在这种情况下,21。
I'm trying to get the value of selected item. In this instance, 21.
推荐答案
这是因为 remoteFunction
写一个JS函数,该函数基于所使用的应答库( JQuery
, DOJO
等)触发AJAX请求。 params
属性是根据您用于您的项目的AJAX库,以原生格式提及的。
This is because remoteFunction
in turn writes a JS function which fires an AJAX request based on the corressponding library used (JQuery
, DOJO
etc). params
attribute is requried to me mentioned in the native format based on the AJAX library you use for your project.
使用不同的库时标记差异
Mark the difference when different libraries are used
JQuery:
'\'user.id = \'+ this.value + \'& report = \'+ $ {reportInstance.id}'
DOJO:[使用分号-value pair]
DOJO: [Use of Semi colons for Key-value pair]
'\'user.id:\'+ this.value + \',report:\' + $ {reportInstance.id}'
这篇关于从combobox onChange事件传递两个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!