jQuery自动完成建议未显示在mvc中的文本框下

时间:2019-05-22 08:58:37

标签: c# asp.net-mvc jquery-ui-autocomplete

我使用的是jQuery自动完成文本框,但没有显示建议,而不是js。

jQuery("#txt-search").autocomplete({
    minLength: 2,
    delay: 500,
    source: function (request, response) {
        jQuery.ajax({
            url: SearchProduct,
            dataType: "json",
            data: {
                searchString: request.term
            },
            success: function (data) {
                response(data);
            }
        });
    },
    focus: function (event, ui) {
        return false;
    },
    select: function (event, ui) {
        jQuery("#table-detail tbody").append("<tr>" +
            "<td class='text-center'>" + (jQuery("#table-detail tbody tr").length + 1) + "</td>" +
            "<td><input type='hidden' name='HangHoaID' value='" + ui.item.HangHoaID + "' >" + ui.item.MaHang + "</td>" +
            "<td>" + ui.item.TenHang + "</td>" +
            "<td class='text-center'>" + ui.item.DonViTinh + "</td>" +
            "<td><input type='text' name='GiaNhap' value='" + ui.item.GiaNhap + "' class='form-control text-right'></td>" +
            "<td><input type='number' name='SoLuong' value='" + ui.item.SoLuong + "' class='form-control text-right' ></td>" +
            "<td class='money TongTien'>" + jQuery.number(ui.item.GiaNhap, 0, '.', ',') + "</td>" +
            "<td class='text-center'><button type='button' class='btn btn-danger btn-xs btn-flat btn-delete-detail'><i class='fa fa-trash-o'></i></button></td>" +
            "</tr>");

        Formula();
        //return false;
    }
})
    .autocomplete("instance")._renderItem = function (ul, item) {
        return jQuery("<li class='search'>")
          .append("<div class='div-item'><div class='text'>" + item.MaHang + "<br>" + item.TenHang + "</div></div>")
          .appendTo(ul);
    };

enter image description here

0 个答案:

没有答案