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

11632Re: Autocomplete - problems with itemSelectEvent

Expand Messages
  • juliusdietz
    Apr 2, 2007
    • 0 Attachment
      Hi "dunxwbl",

      was wha Jason wrote the reason why it didn't work?
      I've got the same problem and doing it the other way round doesn't help...
      Thanks for any help!!

      Julius

      --- In ydn-javascript@yahoogroups.com, "Jason Erickson" <jason@...> wrote:
      >
      > You need to subscribe to the function after it has been created.
      > JavaScript is not compiled, so it is just executed in order. At the
      > time you subscribe, there is no setLocId function, so you just pass
      > undefined.
      >
      > --- In ydn-javascript@yahoogroups.com, "dunxwbl" <duncan@> wrote:
      > >
      > > I need autocomplete to fill a hidden field for me, just like here:
      > > http://tech.groups.yahoo.com/group/ydn-javascript/auth?
      > > check=G&done=http%3A%2F%2Ftech%2Egroups%2Eyahoo%2Ecom%2Fgroup%2Fydn-
      > > javascript%2Fmessage%2F6434
      > >
      > > I have 2.2.0a and I'm using itemSelectEvent in an example based on
      > > the delivered ysearch_flat.html example:
      > >
      > > ---
      > > var myInput = document.getElementById('ysearchinput0');
      > > var myContainer = document.getElementById('ysearchcontainer0');
      > > oAutoComp0 = new YAHOO.widget.AutoComplete
      > > (myInput,myContainer,oACDS);
      > > oAutoComp0.queryDelay = 0.5;
      > > oAutoComp0.maxResultsDisplayed = 20;
      > > oAutoComp0.minQueryLength = 3;
      > > oAutoComp0.formatResult = function(oResultItem, sQuery) {
      > > var sPlace = oResultItem[0];
      > > var nInfo = oResultItem[1];
      > > var hidden_var = oResultItem[2]
      > > var aMarkup = ["<div id='ysearchresult'><div
      > class='ysearchquery'>",
      > > nInfo,
      > > hidden_var,
      > > "</div>",
      > > sPlace,
      > > "</div>"];
      > > return (aMarkup.join(""));
      > > };
      > > oAutoComp0.itemSelectEvent.subscribe(setLocId);
      > > var setLocId = function(oSelf,listItem,dataArray) {
      > > var id = listItem[2]
      > > document.getElementById("loc_id").value = id
      > > }
      > > ---
      > >
      > > The pick list diplayed includes "hidden_var" fine, so I know it's
      > > being returned, but the logger always tells me:
      > >
      > > global:
      > >
      > > 'fn' is null or not an object
      > > (http://www.mydomain.com/test/ysearch_flat.html, line 1544)
      > >
      > > Presumably just a lack of Javascript understanding on my part, but
      > > does anybody got any ideas as my brain has started to melt?
      > >
      > > Cheers
      > > Dunx
      > >
      >
    • Show all 3 messages in this topic