我正在尝试在我的rails应用上实现FullCalendar,我在assets / javascritp文件夹中有以下文件:
fullcalendar.min.js moment.min.js
我的application.js文件中有以下几行:
//= require moment.min
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require jquery.ui.datepicker
//= require twitter/bootstrap
//= require fancybox
//= require zeroclipboard
//= require_tree .
//= require uservoice
//= require fullcalendar.min
然后在我看来,我有以下div与“calendar”id,就像这样(我正在使用haml):
.row
.col-md-12{style: "margin-top:10px;"}
.panel.panel-default
.panel-heading
%i.fa.fa-calendar
Click on the green cells to book a class (calendar)
.panel-body
#calendar
这是我的jquery代码:
:javascript
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultDate: '2014-09-12',
editable: true,
eventLimit: true,
events: [
{
title: 'All Day Event',
start: '2014-09-01'
},
{
title: 'Long Event',
start: '2014-09-07',
end: '2014-09-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-09-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-09-16T16:00:00'
},
{
title: 'Conference',
start: '2014-09-11',
end: '2014-09-13'
},
{
title: 'Meeting',
start: '2014-09-12T10:30:00',
end: '2014-09-12T12:30:00'
},
{
title: 'Lunch',
start: '2014-09-12T12:00:00'
},
{
title: 'Meeting',
start: '2014-09-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2014-09-12T17:30:00'
},
{
title: 'Dinner',
start: '2014-09-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2014-09-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2014-09-28'
}
]
});
});
但它没有用。我检查了开发人员工具,发现了以下错误:
未捕获的TypeError:undefined不是函数
我在html文件上做了同样的事情,一切都很好,所以我不明白我在做什么。
任何帮助都会受到赞赏。感谢
更新
我改变了application.js文件的顺序,如下所示:
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require jquery.ui.datepicker
//= require twitter/bootstrap
//= require fancybox
//= require zeroclipboard
//= require_tree .
//= require uservoice
//= require fullcalendar
//= require moment.min
但现在我有以下错误:
Uncaught ReferenceError: moment is not defined fullcalendar.js?body=1:13
Uncaught ReferenceError: moment is not defined fullcalendar.min.js?body=1:7
答案 0 :(得分:1)
TypeError: Undefined is not a function
错误。任何从属库未加载也会导致此错误。尝试在application.js
文件中交换订单。首先尝试在//= require moment.min
之后加载//= require jquery
。