Why am I getting this JS error?

后端 未结 4 1988
无人及你
无人及你 2020-12-11 04:13

I get this JS error:

jquery-1.5.1.min.js:16Uncaught TypeError: Cannot set property \'_renderItem\' of undefined
d.d.extend._Deferred.f.resolveWithjquery-1.5.         


        
4条回答
  •  余生分开走
    2020-12-11 04:38

    why not just wrap the autocomplete code in a check to see if that element exists?

    something like this:

    if ($'#myElementId').length) {
        $('#myElementId').data( "autocomplete" )._renderItem = function( ul, item ) {
             return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.topic.name + "" ) .appendTo( ul ); }; }

提交回复
热议问题