jQuery的选择框(roblaplaca)定制的滚动条不工作滚动条、工作、jQuery、roblaplaca

2023-09-10 16:34:51 作者:会久伴i

我已经使用 http://www.roblaplaca.com/docs/custom-selectbox/ 自定义选择框剧本,我用了两个选择框,第二个选择框更新的使用AJAX 的变化事件第一个选择框。下面的示例HTML。

I have used http://www.roblaplaca.com/docs/custom-selectbox/ for custom select box script and I have used two select box, second select box updating using AJAX on change event for first select box. Below is sample HTML.

<option>One</option>
<option>Two</option>
<option>Three</option>

我已经使用同步()方法对AJAX成功后更新我的选择框,内容也得到更新,但问题是滚动条消失

我已经检查同步()方法的 selectbox.js 文件调用的 _setupScrollbar(); 内容更新,但乳清滚动条的方法后,没有出现任何的帮助?

I have checked sync() method in selectbox.js file it calls _setupScrollbar(); method after content update but whey scroll bar is not appearing any help on this?

您可以检查演示code

推荐答案

在您的 SelectBox.js 您将需要修改以下codeS

In your SelectBox.js you will need to modify following codes

(1)找到此函数_setupScrollbar()并添加此code autoReinitialise:真正的。 code会显示这个样子的。

(1) Find this function _setupScrollbar() and add this code autoReinitialise: true. Code will be show look like this.

self.scrollpane = $dl.jScrollPane($.extend({
    contentWidth: 200,
    autoReinitialise: true
}, cfg.scrollOptions));

(2)找到该功能 this.sync =功能()和变革code状波纹管。

(2) Find this function this.sync = function() and change code like bellow.

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中被替换为新的内容,所以我已经改变了以下同步code();

Scrollbar is not working because of your jsPane get replaced with new content, so I have changed following code in 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
}

我希望这将解决您的问题。

I hope this will solve your problem.