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

Re: Using AutoComplete Widget for Navigation

Expand Messages
  • aqhost
    That nailed it, thank-you! ... product s ... for ... name is ... eventArgs) { ... http://developer.yahoo.com/yui/docs/YAHOO.widget.AutoComplete.html#eve
    Message 1 of 3 , Apr 2, 2008
    • 0 Attachment
      That nailed it, thank-you!

      --- In ydn-javascript@yahoogroups.com, Fiouz <fiouzy@...> wrote:
      >
      > Hi,
      >
      > On Fri, Mar 28, 2008 at 5:34 PM, aqhost <aqhost@...> wrote:
      > > The name is linked to the URL
      > > so that if you click the product name, you get taken to the
      product's
      > > page on the site.
      > >
      > > myAutoComp.formatResult = function(aResultItem, sQuery)
      > > {
      > > var myURL = aResultItem[1];
      > > var myText = aResultItem[0];
      > > if (myURL == "NOURL")
      > > {
      > > var sMarkup = myText;
      > > }
      > > else
      > > {
      > > var sMarkup = '<a href="' + myURL + '">' + myText
      > > + '</a>';
      > > }
      > > return (sMarkup);
      > > }
      > >
      > > The problem is that this works great for mouse clicks, but not
      for
      > > anyone who uses the Enter key. Additionally only the product
      name is
      > > actually a live link whereas it would be preferable for the whole
      > > <li> element to be linked. Any clues on resolving these problems
      > > please?
      >
      > Try using the itemSelectEvent[1] provided by the AutoComplete class
      instead:
      >
      > myAutoComp.itemSelectEvent.subscribe(function (eventType,
      eventArgs) {
      > var item = eventArgs[2];
      > var url = item[1];
      > if (url !== "NOURL") {
      > window.location.href = url;
      > }
      > });
      >
      > Regards,
      >
      > [1]
      http://developer.yahoo.com/yui/docs/YAHOO.widget.AutoComplete.html#eve
      nt_itemSelectEvent
      >
      > --
      > Fiouz
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.