title: jQuery autocomplete gives TypeError: this._renderItem(...) is undefined
body: <p>I'm currently using <code>.data( "ui-autocomplete" )._renderItem = function( ul, item )</code> in three places in my page. Now I need to add one more and I'm done.</p>
  
  <p>But this time I get the error message </p>
  
  <blockquote>
    <p>TypeError: this._renderItem(...) is undefined</p>
  </blockquote>
  
  <p>The strange thing is that I only get this if my <code>IF</code> test is false.</p>
  
  <pre><code> .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
  
    // If only one row is returned and ID = 0, then return 'no result' message
    if(item.id == '0') {
      return jQuery( "&lt;li&gt;&lt;/li&gt;" )
          .data( "item.autocomplete", item )
          .append( "&lt;div class='no-result'&gt;"+ item.value + "&lt;/div&gt;" )
          .appendTo( ul );
    }
  </code></pre>
  
  <p>I can't figure out why it's failing here, and not in the other 3 places. Is there a conflict somewhere?</p>
  
  <p>This is my code</p>
  
  <pre><code>jQuery('#my-selector').autocomplete({
    minLength: 2,
    source: function( request, response ) {
      jQuery.ajax({
          url: callback_url,
          dataType: "json",
          data: {
                  term: request.term
          },
          success: function( data ) {
            response( jQuery.map( data, function( item ) {
              return {
                id: item.id,
                value: item.name,
                name_encoded: item.name_encoded
              }
          }));
        }
      });
    },
    select: function( event, ui ) {
          return false;
    }
  }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
    if(item.id == '0') {
      return jQuery( "&lt;li&gt;&lt;/li&gt;" )
          .data( "item.autocomplete", item )
          .append( "&lt;div class='no-result'&gt;"+ item.value + "&lt;/div&gt;" )
          .appendTo( ul );
    }
  };
  </code></pre>
  
  <p><strong>Update</strong>  </p>
  
  <p>This change works. But I still don't understand why I must use a <code>else</code> statement here, when I'm not using it in two other <code>autocomplete</code> functions.</p>
  
  <pre><code>.data( "ui-autocomplete" )._renderItemData = function( ul, item ) {
          if(item.id == '0') {
                  return jQuery( "&lt;li&gt;&lt;/li&gt;" )
                          .data( "item.autocomplete", item )
                          .append( "&lt;div class='no-result'&gt;"+ item.value + "&lt;/div&gt;" )
                          .appendTo( ul );
          } else {
              return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
          }
  
  };
  </code></pre>
  
  <p>Return data from query with search term <code>some</code></p>
  
  <pre><code>[
    {"id":"8186","name":"Some Are Thieves"},
    {"id":"6149","name":"Somet"},
    {"id":"6150","name":"Somethin'Else from SKECHERS"}
  ]
  </code></pre>