2017-04-19 34 views
0

我有一個富有問題:選擇組件RichFaces 4.0.0.Final。如何使用java腳本或jQuery來滾動富選中的選項列表?

在滾動並選擇列表中的列表項後,如果我再次打開列表,列表不會自動滾動到所選項目。我必須手動滾動。

任何幫助!

+0

什麼版本的RichFaces的使用?據我記得這是在RichFaces 4.5的一些微版本中實現的。 – Makhiel

+0

RichFaces 4.0.0.Final –

+0

可能重複的[rich:select下拉跳轉到列表中當前選定的項目](http://stackoverflow.com/questions/17718796/richselect-on-drop-down-jump-到目前選定的項目在列表中) – Makhiel

回答

0

重寫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; 
} 
相關問題