javascript 类型错误:document.on 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14417049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:35:49  来源:igfitidea点击:

TypeError: document.on is not a function

javascriptruby-on-railsfullcalendar

提问by Lenny B.

ROR newbie here. I am attempting to use FullCalendarwith ROR 3.2.11 on Ubuntu 12. I've downloaded a working exampleand verified the calender does display in the sample app. However, it does not in my app. I installed Firebug to see if there are any JavaScript errors and there are 2:

ROR新手在这里。我正在尝试在 Ubuntu 12 上使用带有 ROR 3.2.11 的FullCalendar。我已经下载了一个工作示例并验证了日历确实显示在示例应用程序中。但是,它不在我的应用程序中。我安装了 Firebug 以查看是否有任何 JavaScript 错误,并且有 2 个:

TypeError: document.on is not a function   <location rails.js:128>
TypeError: $(...).fullCalendar is not a function   <location calendar.js:48>

I don't understand what the errors mean. Keep in mind I did not write these JavaScripts, so I don't understand them.

我不明白这些错误是什么意思。请记住,这些 JavaScript 不是我写的,所以我不理解它们。

Hoping someone who has come across this error and solution can help.

希望遇到此错误和解决方案的人可以提供帮助。

回答by robrich

$(document).on()is a jQuery construct (see http://api.jquery.com/on/). $(...).fullCalendar()also smells like a jQuery plugin. Reference jQuery earlier in your page (see https://developers.google.com/speed/libraries/devguide#jquery) and it should light up.

$(document).on()是一个 jQuery 结构(参见http://api.jquery.com/on/)。 $(...).fullCalendar()也闻起来像一个 jQuery 插件。在您的页面前面引用 jQuery(请参阅https://developers.google.com/speed/libraries/devguide#jquery),它应该会亮起。

回答by tunmyse

Check your jquery version, it should be at least 1.7 for $(document).on() to work.

检查您的 jquery 版本,$(document).on() 至少应为 1.7 版本。