单击前面类型下拉列表时回发

发布于 2024-09-10 19:24:58 字数 317 浏览 3 评论 0原文

我有一个我创建的头部下拉列表。显然,我必须将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南…巷孤猫 2024-09-17 19:24:58

如果您使用最新版本的 Type Ahead,该库实际上附带了一组可用的回调函数 此处。

要执行回调,只需在初始化类型提前时通过绑定方法将其传入即可。示例代码:

        // attach type-ahead to class
        $autoComplete.typeahead({
            hint: true,
            highlight: true,
            minLength: 1
        }, {
            displayKey: 'value',
            source: substringMatcher($autoCompleteData)
        }).bind("typeahead:selected", function (obj, datum, name) {
            console.log(obj, datum, name);
        });

当用户单击选项或按选项上的返回键时,将执行最后的 .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:

        // attach type-ahead to class
        $autoComplete.typeahead({
            hint: true,
            highlight: true,
            minLength: 1
        }, {
            displayKey: 'value',
            source: substringMatcher($autoCompleteData)
        }).bind("typeahead:selected", function (obj, datum, name) {
            console.log(obj, datum, name);
        });

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文