Rickshaw.Graph.RangeSlider TypeError: $(element).s

2019-05-20 06:17发布

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条回答
混吃等死
2楼-- · 2019-05-20 06:31

You should import jqueryui before using the slider.

http://jqueryui.com/slider/
查看更多
登录 后发表回答