Loading ...
Sorry, an error occurred while loading the content.

Re: Autocomplete and minQueryLength=0...

Expand Messages
  • jennykhan
    Hi Mike, We ll try to get this addressed in a future release. In the meantime, try applying the following patches to get you the desired behavior: As you have
    Message 1 of 2 , Mar 1, 2007
    • 0 Attachment
      Hi Mike,

      We'll try to get this addressed in a future release. In the meantime,
      try applying the following patches to get you the desired behavior:

      As you have already figured out, add the following "else" statement to
      YAHOO.widget.DS_JSArray.prototype.doQuery:

      else {
      for(var i = aData.length-1; i >= 0; i--) {
      if(aData[i] !== null) {
      if(aData[i].constructor == String) {
      aResults.unshift([aData[i]]);
      }
      else if(aData[i].constructor == Array) {
      aResults.unshift(aData[i]);
      }
      }
      }
      }



      Then change YAHOO.widget.AutoComplete.prototype._onTextboxFocus from:

      oSelf._oTextbox.setAttribute("autocomplete","off");
      oSelf._bFocused = true;
      oSelf.textboxFocusEvent.fire(oSelf);


      to:

      oSelf._oTextbox.setAttribute("autocomplete","off");
      oSelf._bFocused = true;
      if(!oSelf._bItemSelected) {
      oSelf.textboxFocusEvent.fire(oSelf);
      }




      And then subscribe to the textboxFocusEvent thusly:

      oAutoComp.textboxFocusEvent.subscribe(function(){oAutoComp.sendQuery("");});




      Let me know how that works for you,
      Jenny





      --- In ydn-javascript@yahoogroups.com, "michael_a_giles" <mgiles@...>
      wrote:
      >
      > It doesn't look like the minQueryLength=0 is fully working, at least
      > not with a DS_JSArray DataSource. As with others on this list, the
      > behavior I want is for the list of choices to pop up when a text
      > fields gets focus.
      >
      > I took a look at the code in autocomplete.js (right at the end of the
      > file) and there's an if check (if(sQuery)) that doesn't have a
      > corresponding else. Hoping it would be a simple hack, I added in an
      > else that mimicked the existing logic:
      > else {
      > for(var i = aData.length-1; i >= 0; i--) {
      > var aDataset = [];
      > if(aData[i]) {
      > if(aData[i].constructor == String) {
      > aDataset[0] = aData[i];
      > }
      > else if(aData[i].constructor == Array) {
      > aDataset = aData[i];
      > }
      > }
      > if(aDataset[0] && (aDataset[0].constructor == String)) {
      > aResults.unshift(aDataset);
      > }
      > }
      > }
      >
      > This makes the list appear if you type in a character and then delete
      > it. But I wanted it to appear onFocus. So, onFocus I called a
      > function that looks like:
      >
      > function showList(field) {
      > if (field && field.value.length == 0) {
      > wrtTagAutoComp.sendQuery("");
      > }
      > }
      >
      > Unfortunately, this only causes the list to appear the first time it
      > executes. If you blur the field and then click back into it, nothing
      > happens (although an alert() placed in the new else clause fires, so
      > the list IS getting created, just not displayed). I assume a flag
      > isn't getting set somewhere when I call sendQuery. Any ideas?
      >
      > At a minimum, there needs to be logic in DS_JSArray to handle empty
      > queries. But it seems like most folks who are interested in that
      > logic want the same thing: the list to appear on focus. So we need a
      > way to make that happen.
      >
      > -Mike
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.