单击前面类型下拉列表时回发
我有一个我创建的头部下拉列表。显然,我必须将 AutoPostBack 设置为 false,否则它会在用户键入时回发。但我想在用户做出选择后回复。
我不想使用提交按钮或类似的东西。长话短说,请相信我,这不是我的情况的解决方案。
在使用单击 Enter 时提前输入的 JavaScript 中,我会回发。那工作很棒。
但是当用户用鼠标单击时呢?所以我使用 onblur 事件来回发。但是,这需要单击下拉列表外部。
我希望当他们单击新项目时发生回发。就像 itemchanged 时的回发一样,但前提是我通过单击它来更改它。
有什么想法吗???
I have a type a head drop down list that I created. Clearly I had to turn the AutoPostBack to false because otherwise it would post back as the user was typing. But I want to poast back when use has made his selection.
I don't wanna use a submit button or anything like that. Long story, just trust me it's not the solution for my situation.
In the javascript that does the type ahead when the use clicks enter I post back. That work great.
However whast about when the user click with the mouse? So I use the onblur event to postback. However that requires clicking outside of the drop down list.
I want the postback to happen when they click the new item. So like a postback when itemchanged, but only if I changed it by clicking on it.
Any ideas???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用最新版本的 Type Ahead,该库实际上附带了一组可用的回调函数 此处。
要执行回调,只需在初始化类型提前时通过绑定方法将其传入即可。示例代码:
当用户单击选项或按选项上的返回键时,将执行最后的 .bind 方法。将 console.log 条目替换为您想要执行的任何操作,即定位提交按钮并触发单击。
Providing your using an up to date version of Type Ahead, the library actually comes with a set of callback functions which are available here.
To execute a callback, just pass it in via a bind method when you initialize type ahead. Example code:
The .bind method on the end will execute when the user either clicks an option or hits the return key on an option. Replace the console.log entry with whatever you want to do, i.e target a submit button a trigger a click.