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

Re: simple yui combobox?

Expand Messages
  • ng.kaye
    Although this feature isn t provided by YUI, I managed to implement this by doing the following: button.onclick = function() { if
    Message 1 of 4 , May 1, 2008
    • 0 Attachment
      Although this feature isn't provided by YUI, I managed to implement
      this by doing the following:

      button.onclick = function() {
      if (!autoCompObj.isContainerOpen()) {
      // Show the drop down, if it isn't already up
      autoCompObj._toggleContainer(true);

      }

      // Populate the list. I've just chosen to show everything, when they
      click on this button.
      autoCompObj._populateList("", autoCompObj.dataSource.data, autoCompObj);
      }

      where autoCompObj is the YUI auto complete object.

      You'll also need to hack the YUI autoComplete.js. Assuming that you're
      using 2.5.1 - in the function _populateList() comment out

      if(!oSelf._bFocused || !aResults) {
      return;
      }

      and replace it with:

      if(!aResults) {
      return;
      }

      The oSelf._bFocused basically checks to see if the control has focus
      before it tries to populate the list. Since you're clicking on a
      button to populate the list, the auto complete control doesn't have
      focus and therefore the drop down won't appear. Hence we need to
      remove the check.

      Hope this helps.

      Cheers,
      Kaye.


      --- In ydn-javascript@yahoogroups.com, "Filip" <filip.hoeven@...> wrote:
      >
      > I have the same question. I want to show an editable combobox like most
      > users are used to have in desktop applications.
      >
      > The YUI Autocomplete component can be used for this but doesn't have
      > the dropdown button with which a user can "dropdown" the list himself.
      >
      > The menu example isn't editable to the user and also doesn't look
      > familiar like a combobox.
      >
      > I suppose I can add a button next to the Autocomplete component, but I
      > don't see a method that I could call to display the popup when the user
      > presses the button.
      >
      > Anyway, I think this would be something that should be added as a
      > component to YUI.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.