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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -