下面的代码来自FullCalendar的Custom View文档。这似乎是一个很好的开始,但对于像我这样全新的人来说,拥有一些基本的代码来呈现最简单的自定义视图(带有一些事件)将是非常有帮助的。他们告诉您将BasicView和AgendaView作为参考,但这有点超出了我的理解。是否每个函数都需要在自定义类中被覆盖?
这个柱塞有一个基本的FullCalendar和一个可以切换到自定义视图的按钮。看一个有效的例子会很有帮助。我已经修修补补了几个小时,但没有成功的自定义视图。如果您了解FullCalendar并愿意为这些函数填写一些代码,将不胜感激!
https://plnkr.co/edit/gfEUCVYTWTm1md24e33m?p=preview
我的目标是构建一个日期列表,在可滚动的div中按顺序列出当天的所有事件(其中每个条目最终都将使用数据和css样式进行充实--我不确定listDay是否允许这种类型的定制??)。
var FC = $.fullCalendar; // a reference to FullCalendar's root namespace
var View = FC.View; // the class that all views must inherit from
var CustomView; // our subclass
CustomView = View.extend({ // make a subclass of View
initialize: function() {
// called once when the view is instantiated, when the user switches to the view.
// initialize member variables or do other setup tasks.
},
render: function() {
// responsible for displaying the skeleton of the view within the already-defined
// this.el, a jQuery element.
},
setHeight: function(height, isAuto) {
// responsible for adjusting the pixel-height of the view. if isAuto is true, the
// view may be its natural height, and `height` becomes merely a suggestion.
},
renderEvents: function(events) {
// reponsible for rendering the given Event Objects
},
destroyEvents: function() {
// responsible for undoing everything in renderEvents
},
renderSelection: function(range) {
// accepts a {start,end} object made of Moments, and must render the selection
},
destroySelection: function() {
// responsible for undoing everything in renderSelection
}
});发布于 2017-09-09 19:19:44
我已经在您的柱塞中添加了几行代码,以使自定义视图正常工作。您可以在此处找到示例:https://plnkr.co/edit/8iOq15CsL2x6RPt29wgE?p=preview
仅提一下更改:在日历初始化器中添加了视图定义
$('#calendar').fullCalendar({
...
views: {
CustomView: {
type: 'custom',
buttonText: 'my Custom View',
click: $('#calendar').fullCalendar('changeView', 'CustomView')
}
}
});在自定义视图中,刚刚在渲染中添加了这个
$('.fc-view').append("<div>Insert your content here</div").css("background", "red");在自定义视图中,您可以通过执行以下操作来访问事件:
var myEvents=$('#calendar').fullCalendar('clientEvents');从那时起,您可以进行进一步的自定义
https://stackoverflow.com/questions/43339490
复制相似问题