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

Problem setting queryMatchContains=true for autocomplete for object instance

Expand Messages
  • lance_travels
    Hi, I m new to this and am trying to configure the Autocomplete to use the queryMatchContains=true function. I am hosting the js files and they are including
    Message 1 of 1 , Apr 29, 2007
    • 0 Attachment
      Hi,
      I'm new to this and am trying to configure the Autocomplete to use the
      queryMatchContains=true function. I am hosting the js files and they
      are including into my test page OK.
      My autocomplete instance is called oAutoComp. I have tried to
      unsuccessfully set the queryMatchContains configuration in the
      following manner:
      oAutoComp.queryMatchContains=true;
      This does not change the configuration however the following does:
      YAHOO.widget.DataSource.prototype.queryMatchContains=true;

      The problem with the later is that it is not specific to one
      autocomplete box. Therefore when there are multiple autocomplete boxes
      on a page all will have the same configuration. I can set the
      container shadow by oAutoComp.useShadow = true;
      Could someone please point out what I'm doing wrong so that each
      autocomplete on a page can have its own configuration.

      My test code is below:

      <html>
      <head>
      <!-- Dependencies -->
      <script type="text/javascript"
      src="../includes/ajax/yahooLib/js/yahoo-dom-event.js"></script>
      <!-- OPTIONAL: Connection (required only if using XHR DataSource) -->
      <script type="text/javascript"
      src="../includes/ajax/yahooLib/js/connection-min.js"></script>
      <!-- OPTIONAL: Animation (required only if enabling animation) -->
      <script type="text/javascript"
      src="../includes/ajax/yahooLib/js/animation-min.js"></script>
      <!-- OPTIONAL: External JSON parser from http://www.json.org/ (enables
      JSON validation) -->
      <script type="text/javascript"
      src="http://www.json.org/json.js"></script>
      <!-- Source file -->
      <script type="text/javascript"
      src="../includes/ajax/yahooLib/js/autocomplete-min.js"></script>
      <link href="../includes/ajax/yahooLib/css/autocomplete.css"
      rel="stylesheet" type="text/css">
      </head>
      <body>
      <!-- AutoComplete begins -->
      <div id="statesmod">
      <form onSubmit="return
      YAHOO.example.ACJSArray.validateForm();">
      <h3>Find a state:</h3>
      <div id="statesautocomplete">
      <input id="statesinput">
      <div id="statescontainer"></div>
      </div>
      </form>
      </div>
      <!-- AutoComplete ends -->


      <script type="text/javascript">

      var statesArray = [
      "Alabama",
      "Alaska",
      "Arizona",
      "Arkansas",
      "California",
      "Colorado",
      "Connecticut",
      "Delaware",
      "Florida" // Entire array not shown
      ];

      // Instantiate first JS Array DataSource
      //oACDS = new YAHOO.widget.DS_JSArray(statesArray);
      oACDS = new YAHOO.widget.DS_JSArray(statesArray);

      // Instantiate first AutoComplete
      oAutoComp = new
      YAHOO.widget.AutoComplete('statesinput','statescontainer', oACDS);

      oAutoComp.autoHighlight=true; //
      oAutoComp.useShadow = true;
      oAutoComp.queryMatchContains = true;

      oAutoComp.textboxFocusEvent.subscribe(function(){oAutoComp.sendQuery("");});
      </script>

      </body>
      </html>
    Your message has been successfully submitted and would be delivered to recipients shortly.