Passing two parameters from combobox onChange event

我的梦境 提交于 2019-12-11 12:02:31

问题


I have the following code:

<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'
                  )}">

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> 

...

I'm trying to get the value of selected item. In this instance, 21.


回答1:


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: [Use of Semi colons for Key-value pair]

'\'user.id:\' + this.value + \', report:\' + ${reportInstance.id}'



来源:https://stackoverflow.com/questions/16194621/passing-two-parameters-from-combobox-onchange-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!