【发布时间】:2014-07-08 03:03:04
【问题描述】:
这是与Rickshaw.Graph.RangeSlider TypeError: $(element).slider is not a function类似的问题
不同之处在于我在使用 Express 框架的 node.js 应用程序中使用 Rickshaw。
我收到错误消息:“TypeError: $(element).slider is not a function”。 (第 2 行)
我在 package.json 文件夹中指定 jquery-ui ("^1.10.5") 作为依赖项。 执行“npm install”并查看 node_modules 文件夹中的 jquery-ui 文件夹。 我不确定为什么它在下面的上下文中丢失,然后导致错误。
$( 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;
}
}
} );
});
更新:
也许我需要使用 Grunt 构建系统?
构建 jQuery UI
jQuery UI 使用 Grunt 构建系统。
要构建 jQuery UI,你必须安装 node.js 然后运行 以下命令:
安装 Grunt CLI npm install -g grunt-cli
克隆 jQuery UI git repo git clone git://github.com/jquery/jquery-ui.git cd jquery-ui
安装节点模块依赖 npm install
运行 concat 任务连接文件 grunt concat
还有许多其他任务可以通过 Grunt 运行。 对于所有任务的列表: grunt --help
【问题讨论】:
标签: jquery node.js express node-modules rickshaw