Rails + Javascript + Uncaught TypeError:Object#<object>没有方法</object>

时间:2013-03-23 04:04:42

标签: javascript jquery ruby-on-rails ruby-on-rails-3.2 asset-pipeline

我正在使用我购买的模板而且我遇到了这个问题:

Uncaught TypeError: Object #<Object> has no method 'peity' in unicorn.dashboard.js:11

这是第11行:

unicorn.peity();

在我的清单文件中,我得到了这个:

//= require admins/cms/excanvas.min
//= require admins/cms/jquery.min
//= require admins/cms/jquery.ui.custom
//= require admins/cms/jquery.uniform
//= require admins/cms/jquery.flot.min
//= require admins/cms/jquery.flot.resize.min
//= require admins/cms/jquery.dataTables.min
//= require admins/cms/jquery.gritter.min
//= require admins/cms/jquery.validate

//= require admins/cms/jquery.peity

//= require admins/cms/jquery.wizard
//= require admins/cms/select2.min
//= require admins/cms/fullcalendar.min
//= require admins/cms/bootstrap.min
//= require admins/cms/bootstrap-colorpicker
//= require admins/cms/bootstrap-datepicker
//= require admins/cms/unicorn

//= require admins/cms/unicorn.dashboard

//= require admins/cms/unicorn.form_common
//= require admins/cms/unicorn.form_validation
//= require admins/cms/unicorn.wizard
//= require admins/cms/unicorn.interface
//= require admins/cms/unicorn.tables
//= require admins/cms/unicorn.charts
//= require admins/cms/unicorn.calendar

这是脚本在模板附带的静态index.html中加载的方式:

<script src="js/jquery.min.js"></script>
<script src="js/jquery.ui.custom.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-colorpicker.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/jquery.uniform.js"></script>
<script src="js/select2.min.js"></script>
<script src="js/unicorn.js"></script>
<script src="js/unicorn.form_common.js"></script>

这就是我的仪表板索引脚本的加载方式:

<script src="/assets/admins/cms/excanvas.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.ui.custom.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.uniform.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.flot.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.flot.resize.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.dataTables.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.gritter.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.validate.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.peity.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/jquery.wizard.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/select2.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/fullcalendar.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/bootstrap.min.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/bootstrap-colorpicker.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/bootstrap-datepicker.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.dashboard.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.form_common.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.form_validation.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.wizard.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.interface.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.tables.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.charts.js?body=1" type="text/javascript"></script>
<script src="/assets/admins/cms/unicorn.calendar.js?body=1" type="text/javascript"></script>

奇怪的是unicorn.dashboard在jquery.peity之后被加载了。另一个额外的事情是,当我打开模板附带的index.html时,它根本不会出现此错误。我不确定问题是什么。我一直在努力解决这个问题,但我根本没有运气。

如果有人可以帮我解决这个问题会很有帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果您(暂时)将您的清单更改为与index.html文件完全匹配,那么事情是否有效?

如果是这样,我怀疑peity,unicorn和其他包含的内容之间存在冲突,可能是explorecanvas。