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

HTML characters on items of a AutoComplete list

Expand Messages
  • Ravi Ambros Wallau
    Hi fellow developers: We are using the AutoComplete component of the YUI to display the list of possible destinations of our messaging system. Our user
    Message 1 of 2 , Oct 9, 2007
      Hi fellow developers:

      We are using the AutoComplete component of the YUI to display the list
      of possible destinations of our messaging system. Our user database
      has a display name/ user name schema. Something like "Display Name
      <username>". If it was an E-Mail software, it would be something like
      "Display Name <E-Mail address>".

      And we need to put this full information in the text field, so in the
      end we may have something like this:

      [Display Name 1 <username1>; Display Name 2 <username2>]

      To achieve that, we download the list of usernames/ displays from the
      server using this format:
      ["display name 1 <username1>","display name 2 <username2>", ...]

      When the user begins to type the username or the display name, after
      typing three characters, the drop down list is shown and then he can
      pick a name.

      The PROBLEM is that, in the drop down list, the value between the
      characters "<" and ">" is never displayed. When the user picks one of
      the names, the full information is displayed on the text box. If we
      escape these HTML characters (using < and >), then the
      information is corrected displayed in the Drop Down List, but the <
      and > are literally putted in the text box field after one item is
      picked up.

      Any hint on how to solve that? How to make the drop down list accepts
      special HTML characters on the items being displayed?

      Regards, Ravi.
    • Ravi Ambros Wallau
      I have found out the answer. On your HTML page, you should overwrite the method formatResult from the YUI: YAHOO.widget.AutoComplete.prototype.formatResult =
      Message 2 of 2 , Oct 10, 2007
        I have found out the answer. On your HTML page, you should overwrite
        the method formatResult from the YUI:

        YAHOO.widget.AutoComplete.prototype.formatResult =
        function(oResultItem, sQuery) {
        var sResult = oResultItem[0];
        if(sResult) {
        return sResult.replace('<', '<').replace('>', '>');
        }
        else {
        return "";
        }
        };

        And this line...
        return sResult.replace('<', '<').replace('>', '>');
        ... has solved my problem.


        --- In ydn-javascript@yahoogroups.com, "Ravi Ambros Wallau"
        <raviaw@...> wrote:
        >
        > Hi fellow developers:
        >
        > We are using the AutoComplete component of the YUI to display the list
        > of possible destinations of our messaging system. Our user database
        > has a display name/ user name schema. Something like "Display Name
        > <username>". If it was an E-Mail software, it would be something like
        > "Display Name <E-Mail address>".
        >
        > And we need to put this full information in the text field, so in the
        > end we may have something like this:
        >
        > [Display Name 1 <username1>; Display Name 2 <username2>]
        >
        > To achieve that, we download the list of usernames/ displays from the
        > server using this format:
        > ["display name 1 <username1>","display name 2 <username2>", ...]
        >
        > When the user begins to type the username or the display name, after
        > typing three characters, the drop down list is shown and then he can
        > pick a name.
        >
        > The PROBLEM is that, in the drop down list, the value between the
        > characters "<" and ">" is never displayed. When the user picks one of
        > the names, the full information is displayed on the text box. If we
        > escape these HTML characters (using < and >), then the
        > information is corrected displayed in the Drop Down List, but the <
        > and > are literally putted in the text box field after one item is
        > picked up.
        >
        > Any hint on how to solve that? How to make the drop down list accepts
        > special HTML characters on the items being displayed?
        >
        > Regards, Ravi.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.