在 remoteFunction 使用更新后调整不同 Select 的值
Adjust Value of a different Select after remoteFunction using update
我希望在 onChange 中发生的远程函数之后更改 'update' 或 'onSuccess' 中单独 'g:select' 的选定值。
普惠制代码:
<g:select name="mainSelect"
id="mainSelect"
from="${mainSelect}"
value="${mSelect}"
optionKey="key"
optionValue="value"
onchange="${remoteFunction (
controller: 'mainController',
action: 'checkValue',
params: '\'value=\' + this.value + \'&value2=\' + otherSelect.value',
onSuccess: '$("#otherSelect").val(data)',
)}"
noSelection="['': '']"/>
<g:select name="otherSelect"
id="otherSelect"
from="${notimportant}"
value="${notimportant2}"
optionKey="key"
optionValue="value" />
remoteFunction "checkValue" 渲染 "Y" 或 "N" 取决于一些变量,我已经将其注销以知道这绝对是 return每次都会。在此之后我似乎无法更改下拉菜单。我的 post 没有 return 任何错误,我只会收到取决于 onSuccess 或更新中的内容的错误。
我试过很多东西,比如:
onSuccess: '$("#otherSelect").val(data)',
或
update: 'otherSelect'
http://docs.grails.org/3.0.0.M1/ref/Tags/remoteFunction.html
onSuccess (optional) - The JavaScript function to call if successful
只需要创建一个 JS 函数来插入 onSuccess,因为直接 Javascript 不想工作。而不是上面的 onSuccess:
onSuccess: 'functionForSelect(data)',
函数:
function functionForSelect(option)
{
document.getElementById("otherSelect").value = option;
}
我希望在 onChange 中发生的远程函数之后更改 'update' 或 'onSuccess' 中单独 'g:select' 的选定值。
普惠制代码:
<g:select name="mainSelect"
id="mainSelect"
from="${mainSelect}"
value="${mSelect}"
optionKey="key"
optionValue="value"
onchange="${remoteFunction (
controller: 'mainController',
action: 'checkValue',
params: '\'value=\' + this.value + \'&value2=\' + otherSelect.value',
onSuccess: '$("#otherSelect").val(data)',
)}"
noSelection="['': '']"/>
<g:select name="otherSelect"
id="otherSelect"
from="${notimportant}"
value="${notimportant2}"
optionKey="key"
optionValue="value" />
remoteFunction "checkValue" 渲染 "Y" 或 "N" 取决于一些变量,我已经将其注销以知道这绝对是 return每次都会。在此之后我似乎无法更改下拉菜单。我的 post 没有 return 任何错误,我只会收到取决于 onSuccess 或更新中的内容的错误。
我试过很多东西,比如:
onSuccess: '$("#otherSelect").val(data)',
或
update: 'otherSelect'
http://docs.grails.org/3.0.0.M1/ref/Tags/remoteFunction.html
onSuccess (optional) - The JavaScript function to call if successful
只需要创建一个 JS 函数来插入 onSuccess,因为直接 Javascript 不想工作。而不是上面的 onSuccess:
onSuccess: 'functionForSelect(data)',
函数:
function functionForSelect(option)
{
document.getElementById("otherSelect").value = option;
}