使用prototype.js和jqplot作为图形

时间:2013-12-06 08:19:19

标签: javascript prototypejs jqplot

我在使用AND prototype.js(菜单中的shows()和fade()函数)和绘制图形的jqplot时遇到了麻烦。

当我加载这样的外部js文件时,原型工作但我没有jqplot图(案例A):

<script src="includes/scriptaculous/prototype.js" type="text/javascript"></script>
<script src="includes/scriptaculous/scriptaculous.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript" src="includes/dist/jquery.js"></script>
<script language="javascript" type="text/javascript" src="includes/dist/jquery.jqplot.js"></script>
<script type="text/javascript" src="includes/dist/jquery.min.js"></script>
<script type="text/javascript" src="includes/dist/jquery.jqplot.min.js"></script>
<link rel="stylesheet" type="text/css" hrf="includes/dist/jquery.jqplot.min.css" />
<link rel="stylesheet" type="text/css" href="includes/dist/jquery.jqplot.css" />
<script type="text/javascript" src="includes/dist/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.pointLabels.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.canvasAxisTickRenderer.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.canvasTextRenderer.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.highlighter.min.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.cursor.min.js"></script>
<script type="text/javascript" src="includes/dist/plugins/jqplot.canvasOverlay.js"></script>

当我第一次加载jqplot文件然后加载原型文件时,我有一个图表但我的菜单中没有导航(案例B)

<script language="javascript" type="text/javascript" src="includes/dist/jquery.js"></script>

如果A我收到错误:

TypeError:element.dispatchEvent不是函数 TypeError:element.getStyle不是函数

如果B我收到错误:

TypeError:$(...)。ready不是函数

我怎样才能同时使用?

感谢。

1 个答案:

答案 0 :(得分:0)

试试这个

加载jQuery

<script language="javascript" type="text/javascript" src="includes/dist/jquery.js"></script>

运行noconflict()

<script language=javascript">jQuery.noConflict()</script>

加载Prototype和Scripty

<script src="includes/scriptaculous/prototype.js" type="text/javascript"></script>
<script src="includes/scriptaculous/scriptaculous.js" type="text/javascript"></script>

然后加载其他所有内容。此外,它看起来像是双重加载jQuery,这将导致问题。

也是错误

$(...).ready is not a function

在这种情况下$()是Prototype方法 - 这是尝试运行jQuery ready()方法 - 找到它并更改为

jQuery(...).ready