jQuery UI 自动完成组合框 - 防止表单提交
我正在使用 jQuery UI 自动完成的漂亮“组合框”变体 - 请参阅此处: http://jqueryui .com/demos/autocomplete/#combobox
我将它放在 Form 元素中,因为它是表单的一部分。
自动完成组合框有一个
我如何阻止它提交?
(注意:这个人也有同样的问题,但他解决了通过删除 form
来实现 - 我不能这样做)
I'm using the nifty 'combobox' variant of jQuery UI Autocomplete - see here: http://jqueryui.com/demos/autocomplete/#combobox
I have it within a Form element because its part of a form.
The Autocomplete Combobox has a <button>
that is used to show the whole drop down list. However when the user presses it, the form submits. This appears to be because the <button>
has a type="submit"
attribute. The whole element is created by the button()
call within the .combobox
fn, see source code.
How do I stop it submitting?
(NB: This guy had the same problem but he fixed it by removing the form
- I can't do that)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,没关系,我已经弄清楚了。
该问题在 jQuery 论坛上进行了讨论:
http://forum .jquery.com/topic/autocomplete-combobox-problem-when-it-is-placed-inside-a-form-tag
他们建议了几种不同的方法来调整自动完成组合的源代码来修复它。最简单的似乎是这样的:
行
更改这
可以防止将
type="submit"
插入到最终按钮中。Ah, nevermind, I figured it out.
The problem is discussed on the jQuery forum here:
http://forum.jquery.com/topic/autocomplete-combobox-problem-when-it-is-placed-inside-a-form-tag
They suggest several different ways of adjusting the source code of the autocomplete combo to fix it. The simplest one seems to be this:
Change the line that says
to
this prevents the
type="submit"
from being inserted into the final button.