在你SelectBox.js,您將需要修改下列代碼
(1)找到此function _setupScrollbar()
並添加該代碼autoReinitialise: true
。代碼將顯示如下所示。
self.scrollpane = $dl.jScrollPane($.extend({
contentWidth: 200,
autoReinitialise: true
}, cfg.scrollOptions));
(2)查找此功能this.sync = function()
並更改代碼如下圖所示。
this.sync = function() {
$options = cfg.selectbox.find("option");
//$dl.html(_renderOptions());
$jpane = $customSelect.find("div.jspPane");
if($jpane.length == 1) // need to check if selectbox having scroll bar?
{
$jpane.html(_renderOptions()); //HTML injected to selectbox having scrollbar
}
else
{
$dl.html(_renderOptions()); //else HTML injected to selectbox not having scrollbar
}
_bindHover();
_setupScrollbar();
};
滾動條不工作,因爲你jsPane的被替換爲新的內容,所以我已經改變了以下同步()代碼;
// $dl.html(_renderOptions());
$jpane = $customSelect.find("div.jspPane");
if($jpane.length == 1) // need to check if selectbox having scroll bar?
{
$jpane.html(_renderOptions()); //HTML injected to selectbox having scrollbar
}
else
{
$dl.html(_renderOptions()); //else HTML injected to selectbox not having scrollbar
}
我希望這能解決您的問題。
創建一個選擇框擺弄修改@rajnikanth代碼,請 – SarathSprakash
我試圖用的jsfiddle但劇本沒有工作,所以我已經把這個示例代碼在我服務器...請你幫我從演示代碼創建小提琴。 – steve
當然。告訴我你的代碼 – SarathSprakash