1. John Fuex
  2. ImprovedDropdown (jQuery Plugin)
  3. Issues
Issue #8 resolved

Preselect selected item in list

lhaemmerle
created an issue

Normally the drop down list will show the entries at the top once it is opened. The following patch for function getImageElement(sourceElement,iconPath) will highlight the selected entry and scroll down to that entry.

{{{

!javascript

[...] newImgElement.click(function (event) { var listControl = getListControlFromOtherControl($(this)); var textControl = getTextControlFromOtherControl($(this)); if (listControl.is(':visible')) { selectFirstMatch(textControl,true); } else { windowDismissOpenLists(listControl); clearFilter(getTextControlFromOtherControl($(this))); showList(listControl) textControl.focus().select(); }

    // Highlight selected item
    var selectElement = getSelectControlFromOtherControl(listControl);
    var selectedListElement = $("[savedValue='" + selectElement.val() + "']");
    selectedListElement.addClass("idd_listItem_Hover");

    // Scroll to proper list entry
    listControl.scrollTop(selectedListElement.position().top + listControl.scrollTop() - 30);

    event.stopPropagation();
    return false;

[...] }}}

Comments (2)

  1. Log in to comment