英文:
Showing holiday events on fullcalendar v3 as in easemytrip mobile view calendar
问题
您正在使用fullcalendar v3进行项目开发。您想要在日历上显示假期,就像附带的图像中标记的红色方框所示。
它应该显示如下:
- 在顶部 - 它将显示每个月的总假期数。
- 它应该像徽章一样标有1、2、3的日期,表示每个月的假期。
- 在每个月底部,应该描述每个月的徽章及其假期名称。
英文:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$(document).ready(function () {
$('#calendar').fullCalendar({
header: {
left: 'today',//'month,basicWeek,basicDay',
center: 'title',
right: 'prev,next'
},
views: {
month: { // name of view
titleFormat: 'MMM YYYY'
// other view-specific options here
}
},
buttonText: {
today: 'Today',
},
defaultDate: '2023-06-09',
fixedWeekCount: false,
showNonCurrentDates: false,
navLinks: false, // can click day/week names to navigate views
editable: false,
eventLimit: false, // allow "more" link when too many events
selectable: true,
selectHelper: true,
dayClick: function (date) {
alert(date.format() + "\n" + calEvent.title);
},
eventClick: function(calEvent) {
alert(calEvent.title);
},
eventSources: [
// your event source
//'/feed1.php',
//'/feed2.php',
{
events: [
{
title: 'FULL',
start: '2023-06-11',
},
//for holidays
{
title: '1',
start: '2023-06-11',
color: '#FFE3A2',
textColor: '#000',
className: 'circle_dot'
},
{
title: 'AVAILABLE',
start: '2023-06-12',
color: '#257e4a',
textColor: '#ffffff',
},
//for holidays
{
title: '2',
start: '2023-06-12',
color: '#FFE3A2',
textColor: '#000',
className: 'circle_dot'
},
{
title: 'FULL',
start: '2023-06-23',
color: '#e66d1d'
},
{
title: 'AVAILABLE',
start: '2023-06-28',
}
],
color: 'black', // an universal option!
textColor: 'yellow', // an universal option!
className: 'text-center'
}
]
});
});
<!-- language: lang-css -->
.circle_dot {
font-size: 9px;
width: 12px;
height: 12px;
background: #FFE3A2;
border-radius: 50%;
color: #000;
align-items: center;
justify-content: center;
font-weight: 500;
position: absolute;
top: 0px;
opacity: 1;
}
<!-- language: lang-html -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/fullcalendar.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.10.2/fullcalendar.min.js"></script>
<div id="calendar"></div>
<!-- end snippet -->
I am using fullcalendar v3 in my project. I want to show holidays on the calendar, as shown on attached image marked in red square box.
It should show following as:
- on the top - it will show total holidays of each month
- it should number 1,2,3 like badge on dates which has holidays for each month
- at the bottom of the month it should describe the badge with the holiday name for each month
答案1
得分: 0
After a lot of research I found an event - eventAfterAllRender and wrote a function to achieve my task
eventAfterAllRender: function (view) {
$('.holidaycount').html('').hide();
$('#holidays-list').html('');
var loop = 0;
$('.circle_dot').each(function () {
loop++;
$('#holidays-list').append("<p class=\"holidayName\"> <span class=\"holidayNo\">" + loop + "</span>" + $(this).find('.fc-title').text() + "</p>");
$(this).find('.fc-title').text(loop);
$('.holidaycount').show();
});
$('.holidaycount').html(loop + ' Holidays');
},
eventSources: [
'/home/getcalendar?bid=test',
'/home/getholidays',
]
<p class="holidaycount"></p> - This line is above calendar month
<div id="holidays-list"></div> - this line is below calendar month
英文:
After a lot of research I found an event - eventAfterAllRender and wrote a function to achieve my task
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
eventAfterAllRender: function (view) {
$('.holidaycount').html('').hide();
$('#holidays-list').html('');
var loop = 0;
$('.circle_dot').each(function () {
loop++;
$('#holidays-list').append("<p class=\"holidayName\"> <span class=\"holidayNo\">" + loop + "</span>" + $(this).find('.fc-title').text() + "</p>");
$(this).find('.fc-title').text(loop);
$('.holidaycount').show();
});
$('.holidaycount').html(loop + ' Holidays');
},
eventSources: [
'/home/getcalendar?bid=test',
'/home/getholidays',
]
<!-- language: lang-html -->
<p class="holidaycount"></p> - This line is above calendar month
<div id="holidays-list"></div> - this line is below calendar month
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论