在您的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 被新内容替换,所以我在 sync(); 中更改了以下代码;
// $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
}
我希望这能解决你的问题。