AJAX自动完成功能不适用于动态添加的字段

时间:2015-06-29 12:53:00

标签: jquery ajax autocomplete

<input type="text" class="form-control2 ui-autocomplete-input departure" name="departure" style="text-align:center" id="departure1" maxlength="4"  autocomplete="off">
<input type="text" class="form-control2 ui-autocomplete-input departure" name="departure" style="text-align: center; border-color: rgb(224, 224, 224);" id="departure12" maxlength="4"  autocomplete="off">
$(".departure").each(function(){
    $(this).autocomplete({
        minLength : 3,
        source : function(request, response) {
            $.ajax({
                url : "/FDTL/SearchController",
                type : "POST",
                data : {
                    term : request.term
                },
                dataType : "json",
                success : function(data) {
                    response(data.slice(0, 10));
                }
            });
        }
    });
});

0 个答案:

没有答案