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

Autocomplete with forceSelection:true clears selection on blur

Expand Messages
  • cuz_dawg
    After selecting an Autocomplete value, if I then tab through the field without changing anything / typing anything, the previously selected value dissapears.
    Message 1 of 1 , Jun 30, 2008
    • 0 Attachment
      After selecting an Autocomplete value, if I then tab through the field
      without changing anything / typing anything, the previously selected
      value dissapears. Is this because I'm using the itemSelectEvent to set
      the value of the input field and the Autocomplete can't then determine
      whether that value is valid?

      var dmsUsersDs;
      function setupAutoCompletes() {
      dmsUsersDs = new
      YAHOO.widget.DS_JSArray(flattenObjectArrayMulti(users, ["fullname",
      "userid"]));
      var els = Dom.getElementsByClassName("usersAutoComplete", "div",
      document.body);
      Dom.batch(els, setupDmsUsersAutoComplete);
      }

      function setupDmsUsersAutoComplete(el) {
      var input = el.childNodes[0];
      var container = el.childNodes[2];

      lookup = new YAHOO.widget.AutoComplete(input, container, dmsUsersDs);
      lookup.input = input;
      lookup.prehighlightClassName = "yui-ac-prehighlight";
      lookup.animVert = false;
      lookup.animHoriz = false;
      lookup.useShadow = true;
      lookup.useIFrame = true;
      lookup.forceSelection = true;
      lookup.maxResultsDisplayed = 50;
      lookup.formatResult = function(item, query) {
      var html = item[0] + " (" + item[1] + ")";
      return (html);
      };
      lookup.itemSelectEvent.subscribe(dmsUserSelect);
      }

      function dmsUserSelect(type, args) {
      args[0].input.value = args[2][1];
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.