在多个输入的Jquery自动完成中没有获得输入的当前用户输入值?

时间:2012-12-24 06:46:26

标签: jquery autocomplete

您好我正在使用Jquery自动完成多个输入标记。我的问题是我无法在自动完成功能中获取当前用户输入值。

这是我的代码

 function Call() {

var str = $("#auto").val();
var substr = str.split(',');

$(".inputcatalog").each(function () {

    var classes = $(this).attr("class").split(" ");
    var id = classes[classes.length - 1];
    $this = $(this);

    var stype = id;
    var srctxt = $this.val();

    substr.forEach(function (item) {
        if (id == item) {
            AutoComplete($this, stype)
        }

    });


});


 }

//我的Autocompete功能

 function AutoComplete(object, filter) {

$this = object;
var stype = filter;
var srctxt = $this.val();
$this.autocomplete({
    source: function (request, response) {
        $.getJSON('/Cataloging/Bib/AutoComplete',
             {

                 stype: stype,
                 term: $this.val()
             }, response);
    },
    select: function (event, ui) {

        // Do something with "ui.item.Id" or "ui.item.Name" or any of the other properties you selected to return from the action
    }
});

 }

我的期限值为空

1 个答案:

答案 0 :(得分:0)

在源函数中,request参数是一个term作为属性的对象:

尝试使用:

term: request.term

而不是

term: $this.val()

API参考:http://api.jqueryui.com/autocomplete/#option-source

相关问题