Rickshaw.Graph.RangeSlider TypeError: $(element).slider is not a function

眉间皱痕 提交于 2019-12-10 10:48:00

问题


I have this error: TypeError: $(element).slider is not a function

with the following script:

Rickshaw.namespace('Rickshaw.Graph.RangeSlider');

Rickshaw.Graph.RangeSlider = function(args) {

var element = this.element = args.element;
var graph = this.graph = args.graph;

$( function() {
    $(element).slider( {

        range: true,
        min: graph.dataDomain()[0],
        max: graph.dataDomain()[1],
        values: [ 
            graph.dataDomain()[0],
            graph.dataDomain()[1]
        ],
        slide: function( event, ui ) {

            graph.window.xMin = ui.values[0];
            graph.window.xMax = ui.values[1];
            graph.update();

            // if we're at an extreme, stick there
            if (graph.dataDomain()[0] == ui.values[0]) {
                graph.window.xMin = undefined;
            }
            if (graph.dataDomain()[1] == ui.values[1]) {
                graph.window.xMax = undefined;
            }
        }
    } );
} );

$(element)[0].style.width = graph.width + 'px';

graph.onUpdate( function() {

    var values = $(element).slider('option', 'values');

    $(element).slider('option', 'min', graph.dataDomain()[0]);
    $(element).slider('option', 'max', graph.dataDomain()[1]);

    if (graph.window.xMin == undefined) {
        values[0] = graph.dataDomain()[0];
    }
    if (graph.window.xMax == undefined) {
        values[1] = graph.dataDomain()[1];
    }

    $(element).slider('option', 'values', values);

} );
};

From the following page: https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Graph.RangeSlider.js

The javascript debugger show me this line: slide: function( event, ui ) {

Can you show me a way to resolve my problem. Thanks you!


回答1:


You should import jqueryui before using the slider.

http://jqueryui.com/slider/


来源:https://stackoverflow.com/questions/13645833/rickshaw-graph-rangeslider-typeerror-element-slider-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!