admin管理员组文章数量:1430093
I have troubles with fullCalendar. I am using week view(defaultView: 'basicWeek'), and the toolbar buttons 'today', 'prev', 'next'. And when I click 'today' button is clicked calendar navigates back to current week, but date selection doesn't change. I want calendar to navigate to current week and select today date on the calendar. But I am having troubles with redefining 'today' button click event.
Code sample:
defaultView: 'basicWeek',
defaultDate: '2016-01-12',
selectable: true,
selectHelper: true,
select: function(start, end) {
console.log('select');
var title = prompt('Event Title:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
}
I want a popup(alert) for today date to appear when I clicked 'today' button in this case.So basicly the button click not only navigate me to current week, but to select current day.
I have troubles with fullCalendar. I am using week view(defaultView: 'basicWeek'), and the toolbar buttons 'today', 'prev', 'next'. And when I click 'today' button is clicked calendar navigates back to current week, but date selection doesn't change. I want calendar to navigate to current week and select today date on the calendar. But I am having troubles with redefining 'today' button click event.
Code sample: https://plnkr.co/edit/dv9yiq1CdJxfFTsDg4Yx?p=preview
defaultView: 'basicWeek',
defaultDate: '2016-01-12',
selectable: true,
selectHelper: true,
select: function(start, end) {
console.log('select');
var title = prompt('Event Title:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
}
I want a popup(alert) for today date to appear when I clicked 'today' button in this case.So basicly the button click not only navigate me to current week, but to select current day.
Share Improve this question edited Mar 10, 2016 at 8:35 Yana Karpinska asked Mar 9, 2016 at 12:47 Yana KarpinskaYana Karpinska 631 silver badge6 bronze badges 1- could you provide some code? – Guy Commented Mar 9, 2016 at 13:37
2 Answers
Reset to default 2You can manually listen to the today's button click and then call calendar's select method passing correct arguments.
Try the following code: https://plnkr.co/edit/62Dx5pVrDDXnwoME5jbU?p=preview
calendar.find('.fc-today-button').click(function(){
var start = new Date();
start.setHours(0,0,0,0);
var end = new Date();
end.setDate(end.getDate() + 1);
end.setHours(0,0,0,0);
calendar.fullCalendar('select', start, end);
});
try :
this.calendarComponent.calendar.today()
or
this.calendar.getApi().changeView('resourceTimelineWeek','2022-07-26')
本文标签: javascriptfullCalendar today button custom behaviorStack Overflow
版权声明:本文标题:javascript - fullCalendar today button custom behavior - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745551001a2662943.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论