javascript - 更新 Bootstrap slider 的刻度值

标签 javascript jquery twitter-bootstrap slider bootstrap-slider

我正在尝试根据应用程序上所做的一些更改来更新 Bootstrap slider 的值。

它给出了这个错误:$(...).setAttribute不是一个函数

此问题已记录在 gitHub 上 https://github.com/seiyria/bootstrap-slider/issues/451

我已做出建议的更改

if (updateSlider === true) {
                    if (Array.isArray(this.options.ticks_labels) && this.options.ticks_labels.length > 0) { 
                        for (i = 0; i < this.options.ticks_labels.length; i++) {        
                            this.tickLabels[i].innerHTML = this.options.ticks_labels[i]
                        }
                    }
                }

这是更新它的代码。

function UpdateMonthSlider(month)
{
    var updtdArray = GetTicksArray(month.MonthMin, month.MonthMax, monthStep);
    $('#monthSlider').setAttribute("ticks", updtdArray);
    $('#monthSlider').setAttribute("ticks_labels",  GetFormattedLabels(updtdArray, 'months', false));
    $('#monthSlider').slider('refresh');
}

显示错误的示例 fiddle : jsfiddle.net/mo6v9x7h/2

最佳答案

请尝试这个:

$('#monthSlider').slider('setAttribute', 'ticks', updtdArray);

关于javascript - 更新 Bootstrap slider 的刻度值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40405771/

相关文章:

javascript - 恶意编码的 JavaScript - 它有什么作用?

javascript - 在 html Canvas 上使用图像作为按钮

C# MVC 3/jQuery 预览按钮 CMS

javascript - Bootstrap 工具提示 - 使用 jquery 动态更改 css 和位置

html - 在 bootstrap 中对齐列

javascript - 即使预加载了图像数组,性能也很差

javascript - controllerAs 在指令的链接功能中不起作用

javascript - 如何在前面的 div 仍然可以滚动的情况下临时禁用背景 div 滚动?

javascript - 无法在 knockout js 中获取可观察的数据

button - 单击 twitter bootstrap modal 的取消按钮时如何重新加载当前页面?