jQuery的选择框(roblaplaca)定制的滚动条不工作 [英] jQuery Select box (roblaplaca) with custom scroll bar not working

查看:163
本文介绍了jQuery的选择框(roblaplaca)定制的滚动条不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 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.

这篇关于jQuery的选择框(roblaplaca)定制的滚动条不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆