未捕获的TypeError:无法设置未定义的属性'_renderItem'

时间:2019-05-15 07:34:40

标签: javascript

jQuery(document).ready(function ($) {
        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 data-id=" + ui.item.SanPhamID + " data-gianhap=" + ui.item.GiaNhap + ">" +
                    "<td class='text-center'>" + (jQuery("#table-detail tbody tr").length + 1) + "</td>" +
                    "<td>" + ui.item.SanPhamID + "</td>" +                   
                    "<td><input type='number' name='SoLuong' value='" + ui.item.SoLuong + "' class='form-control text-right' ></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();
                console.log("Formula()" + Formula())               
            }

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

0 个答案:

没有答案