[ 3 posts ]

Paul Robertson

  • Username: paulrobe
  • Joined: Fri Jun 19, 2009 6:51 am
  • Posts: 6
  • Offline
  • Profile
Tags:

AutoComplete 2.7 problem

Post Posted: Tue Jun 23, 2009 7:10 am
+0-
I am currently attempting to set up AutoComplete and it seems that I am having some odd behaviour. What I am trying to do is be able to focus on an AutoComplete field when there are no contents in it and have the container appear with possible results.

It appears that when I click on the text nothing happens, however if I click on the white space to the right of the text, my selection goes through. I have also noticed that this example code only works in Firefox and I need it to also work in IE.

Any advice on how to fix this is greatly appreciated.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css" />
   <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/autocomplete/assets/skins/sam/autocomplete.css" />
   <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
   
   <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js"></script>
   <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/datasource/datasource-min.js"></script>
   <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/autocomplete/autocomplete-min.js"></script>
   
   <script type="text/javascript">
   var array = [
      ["1", "one"],
      ["2", "two"],
   ];
   function init(){
      AC = function() {
      var oDS = new YAHOO.util.LocalDataSource(array);
      oDS.resultTypeList = false;
      
      var oAC = new YAHOO.widget.AutoComplete("input2", "container2", oDS);
      oAC.minQueryLength = 0;
      oAC.textboxFocusEvent.subscribe(function(){
         var sInputValue = this._elTextbox.value;
         if(sInputValue.length === 0)
            this.sendQuery(sInputValue);
      });
   
      oAC.resultTypeList = false;
      oAC.formatResult = function(oResultData, sQuery, sResultMatch) {
         return (oResultData[0] + " ("+oResultData[1] + ")");
      };
      
      return {
         oDS: oDS,
         oAC: oAC
      };
   }();
   }
   </script>

   <style type="text/css">
   #myAutoComplete {
       width:15em;
       padding-bottom:2em;
   }
   </style>
</head>

<body class="yui-skin-sam" onLoad="init()">
   <div id="myAutoComplete">
      <input id="Input" type="text">
      <div id="Container"></div>
   </div>
   <div id="myAutoComplete">
      <input id="input2" type="text">
      <div id="container2"></div>
   </div>
</body>
</html>

Paul Robertson

  • Username: paulrobe
  • Joined: Fri Jun 19, 2009 6:51 am
  • Posts: 6
  • Offline
  • Profile
Tags:

Re: AutoComplete 2.7 problem

Post Posted: Wed Jun 24, 2009 5:15 am
+0-
It seems I have fixed the problem where it does not work in IE.

oDS.resultTypeList = false;
should be:
oDS.responseSchema = {fields: ["name", "moreData"]};

and
return (oResultData[0] + " ("+oResultData[1] + ")");
should be:
return (oResultData.name + " (" + oResultData.moreData + ")");

When testing there seems to be no problems with IE however the problem I listed above still exists in Firefox

Jenny Donnelly

YUI Developer

  • Username: jenny
  • Joined: Tue Dec 09, 2008 5:00 pm
  • Posts: 58
  • GitHub: jenny
  • Gists: jenny
  • YUI Developer
  • Offline
  • Profile

Re: AutoComplete 2.7 problem

Post Posted: Wed Aug 05, 2009 5:52 pm
+0-
Hi Paul,

This seems to be the same issue as tracked in this bug:
http://yuilibrary.com/projects/yui2/ticket/2528002

It should be fixed in the latest build and available in the next release.

Cheers,
Jenny
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum