javascript - TypeError: $(...).autocomplete(...).data(...) is undefined -
i found error when using jquery autocomplete.
this notice error in console
typeerror: $(...).autocomplete(...).data(...) undefined }).data( "ui-autocomplete" )._renderitem = function( ul, item ) {
code:
site name <br/> <input type="text" name="site_name" id="site_name"><br/> <input type="hidden" name="site_id" id="site_id"> $().ready(function () { $("#site_name").autocomplete({ source: function (request, response) { $.ajax({ url: "get_site2.php", datatype: "json", data: { term: request.term }, beforesend: function () { // add showloading("remove"); console.log("remove"); }, success: function (data) { response(data); } }); }, minlength: 2, select: function (event, ui) { $("#site_name").val(ui.item.label); $("#site_id").val(ui.item.name); return false; }, open: function () { $(this).removeclass("ui-corner-all").addclass("ui-corner-top"); }, close: function () { $(this).removeclass("ui-corner-top").addclass("ui-corner-all"); } }).data("ui-autocomplete")._renderitem = function (ul, item) { return $("<li></li>") .data("ui-autocomplete-item", item) .append("<a>" + item.label + "</a>") .appendto(ul); }; });
i confused, search , try this question did not fix it.
sorry fix might bit late .. other guys running problem.
just change
}).data("ui-autocomplete")._renderitem = function (ul, item) {
to
})._renderitem = function (ul, item) {
this should resolve issue.
in cases this
.autocomplete().data("uiautocomplete")._renderitem = function( ul, item )
change to
.autocomplete()._renderitem = function( ul, item )
Comments
Post a Comment