jQuery的自动完成与typewatch [英] jquery autocomplete with typewatch

查看:109
本文介绍了jQuery的自动完成与typewatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个jQuery新手,并试图与jQuery typewatch一起实现自动完成功能。也就是说,为了获得从web服务的数据的一定时间段之后说,而750毫秒比的minLength后

I am a jQuery newbie and trying to implement the autocomplete functionality along with jQuery typewatch. That is, to get the data from web service after a certain time period say 750 ms rather than after minLength.

<script type="text/javascript">
    $(document).ready(function () {
        $('.searchinput').autocomplete({
            source: function (request, response) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "/Services/SampleWebService.asmx/GetProduct",
                    data: '{"searchString":"' + request.term + '"}',
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        response(data);
                    }
                });
            },
        });
        $('.searchinput').typewatch({
            callback: $.autocomplete,
            wait: 750,
            highlight: false
        });
    });

我的自动完成事情的作品精美绝伦,但不知何故,我不能够包括typewatch的事情吧。我相信有一个严重的编码失效而我不知道的。

My autocomplete thing works absolutely fine but somehow I am not able to include the typewatch thing to it. I am sure there is a serious coding failure which I am not aware of.

感谢

推荐答案

jQuery的自动完成有这个选项作为参数调用延迟:

The jquery autocomplete have this option as parameter called delay:

http://api.jqueryui.com/autocomplete/#option-delay

所以,你必须做的是改变这种状况的参数,并删除typewatch为:

So what you have to do is to change that parameter, and remove the typewatch as:

  $(document).ready(function () {
        $('.searchinput').autocomplete({
            delay:750,
            source: function (request, response) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "/Services/SampleWebService.asmx/GetProduct",
                    data: '{"searchString":"' + request.term + '"}',
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        response(data);
                    }
                });
            },
        });
    });

这篇关于jQuery的自动完成与typewatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆