【问题标题】:How to scroll options list in rich select using java script or jquery?如何使用 javascript 或 jquery 在富选择中滚动选项列表?
【发布时间】:2017-04-19 12:59:12
【问题描述】:

我对 Rich:select 组件 RichFaces 4.0.0.Final 有疑问。

滚动并选择列表中的列表项后,如果我再次打开列表,列表不会自动滚动到所选项目。我必须手动滚动。

任何帮助!

【问题讨论】:

标签: richfaces


【解决方案1】:

覆盖 select.js 的 __onBtnMouseDown 函数修复了问题:

__onBtnMouseDown: function(e) {
if(!this.popupList.isVisible()) {
    var selectedSymbol = this.__getValue();
    var selectedSymbolIndex;
    var offset = 0;

    // loop over list to get selected symbol index
    for (var i = 0; i < this.cache.originalValues.length; i++) {
        if(this.cache.originalValues[i] == selectedSymbol){
            selectedSymbolIndex = i;
        }
    }

    if(this.items.length > 0 && this.enableManualInput) {
        $(document.getElementById(this.id+"Items")).empty().append(this.items);
    }

    this.__showPopup();

    if(selectedSymbolIndex >= 0){
        offset = selectedSymbolIndex * this.items.get(selectedSymbolIndex).offsetHeight;
        this.popupList.__selectByIndex(selectedSymbolIndex);
        var parentContainer = $(document.getElementById(this.id + "Items")).parent()[0];
        parentContainer.scrollTop = offset;
    }

} else {
    this.__hidePopup();
}
this.isMouseDown = true;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    • 2022-11-23
    • 2019-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多