Autocomplete Combobox search method not working

Autocomplete Combobox search method not working

I have the following jQuery UI Combobox. When I click on the "show all" button, it searches for the value in the input box, instead of displaying  all items. The line input.autocomplete("search", "") is supposed to display all items. However, it seems to ignore it. Any help would be greatly appreciated.

  1.     (function($) {
  2.         $.widget("custom.combobox", {
  3.             _create: function() {
  4.                 this.wrapper = $("<span>")
  5.                     .addClass("custom-combobox")
  6.                     .insertAfter(this.element);
  7.    
  8.                 this.element.hide();
  9.                 this._createAutocomplete();
  10.                 this._createShowAllButton();
  11.    
  12.                 this.input.data("ui-autocomplete")._renderItem = function(ul, item) {
  13.                     return $("<li></li>")
  14.                         .data("ui-autocomplete-item", item)
  15.                         .append('<a id="plan_' + item.id + '">' + item.label + '</a>')
  16.                         .appendTo(ul);
  17.                 }
  18.             },
  19.    
  20.             _createAutocomplete: function() {
  21.                 var selected = this.element.children(":selected");
  22.                 var value = selected.val() ? $.trim(selected.text()) : "";
  23.                 var cache = {};
  24.                 var term = "";
  25.    
  26.                 this.input = $('<input id="plan_id" name="plan_id">')
  27.                     .appendTo(this.wrapper)
  28.                     .val(value)
  29.                     .attr("title", "")
  30.                     .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
  31.                     .autocomplete({
  32.                         delay: 250,
  33.                         minLength: 0,
  34.                         source: function(request, response) {
  35.                             var term = request.term;
  36.    
  37.                             if (term in cache) {
  38.                                 response(cache[term])
  39.                                 return;
  40.                             }
  41.                             $.ajax({
  42.                                 url: "get_plans.cfm",
  43.                                 data: {
  44.                                     time: new Date().getTime(),
  45.                                     term: $("#plan_id").val()
  46.                                 },
  47.                                 dataType: "json",
  48.                                 success: function(data) {
  49.                                     cache[term] = $.map(data.info, function(item) {
  50.                                         return {
  51.                                             label: item.label,
  52.                                             value: item.clean,
  53.                                             id: item.value
  54.                                         }
  55.                                     })
  56.                                     response($.map(data.info, function(item) {
  57.                                         return {
  58.                                             label: item.label,
  59.                                             value: item.clean,
  60.                                             id: item.value
  61.                                         }
  62.                                     }));
  63.                                 }
  64.                             });
  65.                         }
  66.                     })
  67.                     .tooltip({ tooltipClass: "ui-state-highlight" })
  68.    
  69.                 this._on(this.input, {
  70.                     autocompleteselect: function(event, ui) {
  71.                         ui.item.value = $.trim(ui.item.value);
  72.                     },
  73.                     autocompletechange: "_removeIfInvalid"
  74.                 });
  75.             },
  76.    
  77.             _createShowAllButton: function() {
  78.                 var input = this.input;
  79.                 var wasOpen = false;
  80.    
  81.                 $("<a>")
  82.                     .attr("tabIndex", -1)
  83.                     .appendTo(this.wrapper)
  84.                     .button({
  85.                         icons: { primary: "ui-icon-triangle-1-s" },
  86.                         text: false
  87.                     })
  88.                     .removeClass("ui-corner-all")
  89.                     .addClass("ui-corner-right ui-button-icon")
  90.                     .mousedown(function() { wasOpen = input.autocomplete("widget").is(":visible"); })
  91.                     .click(function() {
  92.                         if (wasOpen) {
  93.                             return;
  94.                         }
  95.    
  96.                         $(this).blur();
  97.                         input.autocomplete("search");
  98.                         input.focus();
  99.                     })
  100.             },
  101.    
  102.             _source: function(request, response) {
  103.                 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
  104.    
  105.                 response(this.element.children("option").map(function() {
  106.                     var text = $(this).text();
  107.    
  108.                     if (this.value && (! request.term || matcher.test(text))) {
  109.                         return {
  110.                             label: text,
  111.                             value: text,
  112.                             option: this
  113.                         };
  114.                     }
  115.                 }));
  116.             },
  117.    
  118.             _removeIfInvalid: function( event, ui ) {
  119.                 if (ui.item) {
  120.                     return;
  121.                 }
  122.    
  123.                 var value = this.input.val();
  124.                 var valueLowerCase = value.toLowerCase();
  125.                 var valid = false;
  126.    
  127.                 this.element.children("option").each(function() {
  128.                     if ($(this).text().toLowerCase() === valueLowerCase ) {
  129.                         this.selected = valid = true;
  130.                         return false;
  131.                     }
  132.                 });
  133.    
  134.                 if (valid) {
  135.                     return;
  136.                 }
  137.    
  138.                 this.input.val("").tooltip("open");
  139.                 this.element.val("");
  140.                 this._delay(function() { this.input.tooltip("close").attr("title", ""); }, 2500);
  141.                 this.input.autocomplete("instance").term = "";
  142.             },
  143.    
  144.             _destroy: function() {
  145.                 this.wrapper.remove();
  146.                 this.element.show();
  147.             }
  148.         })
  149.     })(jQuery);