圣杯。在选择更改时提交给控制器/操作
我想提交一个表单来执行选择框更改的操作(当选择一个项目时,我需要更新另一个选择框,也许还有其他字段)。以下代码将表单提交到表单元素上定义的控制器/操作。
<g:select onchange="submit()"/>
我如何将表单提交给自定义操作? 我想在页面上放置一个隐藏的操作提交,并在选择框中选择一个项目时触发单击它,但希望有一种更优雅的方式。 该项目使用jquery,因此原型库不可用。 多谢 !
I would like to submit a form to an action on select box change (when an item is selected I need to update another select box and maybe other fields). The following code will submit the form to the controller/action defined on form element.
<g:select onchange="submit()"/>
How could I submit the form to a custom action ?
I think to put a hidden action submit on the page and trigger a click on it when selecting an item in the select box, but hopping there is a more elegant way.
The project use jquery, so the prototype library isn't available.
Thanks a lot !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅仅因为一个组合框发生更改就提交整个表单是一种不寻常的用例。通常,仅提交组合框的新值以下内容就足够了。
但是,如果您真的希望也提交所有其他表单字段,我想最好是有一个调度操作,并且您的输入框在提交到标准表单操作之前设置一些隐藏字段。隐藏的提交按钮很可怕:)
It is an unusal use-case to submit the whole form, just because one combo box is changed. Usually the following is sufficient submitting only the new value of the combo box.
However, if your REALLY want to have all other form fields to be submitted as well, I guess it would be the best, to have one dispatching action and your input box sets some hidden field before submitting to the standard form-action. Hidden submit buttons are scary :)