I would be glad if someone help me for javascript. My code works and it shows the data in this way. but I need to show it with array, which I couldn't. Thanks for all help!!:)) so this is my jquery code:
jQuery(document).ready(function () {
_user = JSON.parse('@Html.Raw(Json.Serialize(Model.User))');
KTCalendarBasic.init();
user_appointments_list = _user.user_appointments;
for (var i = 0; i < user_appointments_list.length; i++) {
user_appointment_date_list[i] = user_appointments_list[i].appointment_time;
}
});
and this is my fullcalendar usage. it works fine for one json data object.
var KTCalendarBasic = function () {
return {
init: function () {
events:
[
{
title: 'Hatırlatıcı',
start: _user.user_reminders[0].remind_date,
end: _user.user_reminders[0].remind_date,
description: "NOT: " + _user.user_reminders[0].note + " GAYRİMENKUL ADRESİ: " + _user.user_reminders[0].asset_address + " MÜŞTERİ: " + _user.user_reminders[0].customer_full_name + " MÜŞTERİ TELEFONU: " + _user.user_reminders[0].customer_phone,
className: "fc-event-danger fc-event-solid-warning"
},
{
title: 'Randevu',
//start: YM + '-14T13:30:00',
start: _user.user_appointments[0].appointment_time,
description: "ADRES: " + _user.user_appointments[0].appointment_place + " MÜŞTERİ: " + _user.user_appointments[0].customer_full_name,
//description: _user.user_appointments.appointment_time,
end: _user.user_appointments[0].appointment_time,
className: "fc-event-success",
}
],
eventRender: function (info) {
var element = $(info.el);
if (info.event.extendedProps && info.event.extendedProps.description) {
if (element.hasClass('fc-day-grid-event')) {
element.data('content', info.event.extendedProps.description);
element.data('placement', 'top');
KTApp.initPopover(element);
} else if (element.hasClass('fc-time-grid-event')) {
element.find('.fc-title').append('<div class="fc-description">' + info.event.extendedProps.description + '</div>');
} else if (element.find('.fc-list-item-title').lenght !== 0) {
element.find('.fc-list-item-title').append('<div class="fc-description">' + info.event.extendedProps.description + '</div>');
}
}
}
});
calendar.render();
}
};
}();
I have to fix it with array which I write and it turns correctly in jquery part. I have to implement this array inside the fullcalendar usage part. Thank you!:))
init: function () {
for (var j = 0; j < user_appointment_date_list.length; j++) {
var currentValue = user_appointment_date_list[j];
var todayDate = moment().startOf('day');
I tried this code. and rewrite the event part. the final whole code is:
var KTCalendarBasic = function () {
return {
//main function to initiate the module
init: function () {
for (var j = 0; j < user_appointment_date_list.length; j++) {
var currentValue = user_appointment_date_list[j];
var todayDate = moment().startOf('day');
var YM = todayDate.format('YYYY-MM');
var YESTERDAY = todayDate.clone().subtract(1, 'day').format('YYYY-MM-DD');
var TODAY = todayDate.format('YYYY-MM-DD');
var TOMORROW = todayDate.clone().add(1, 'day').format('YYYY-MM-DD');
var calendarEl = document.getElementById('kt_calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['bootstrap', 'interaction', 'dayGrid', 'timeGrid', 'list'],
themeSystem: 'bootstrap',
isRTL: KTUtil.isRTL(),
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
height: 800,
contentHeight: 780,
aspectRatio: 3, // see: https://fullcalendar.io/docs/aspectRatio
nowIndicator: true,
//now: TODAY + 'T09:25:00', // just for demo
views: {
dayGridMonth: { buttonText: 'month' },
timeGridWeek: { buttonText: 'week' },
timeGridDay: { buttonText: 'day' }
},
defaultView: 'dayGridMonth',
defaultDate: TODAY,
editable: false,
eventLimit: true, // allow "more" link when too many events
navLinks: true,
events:
[
{
title: 'Hatırlatıcı',
//start: user_appointment_date_list,
//start: item.remind_date,
//end: item.remind_date,
//description: "NOT: " + item.note + " GAYRİMENKUL ADRESİ: " + item.asset_address + " MÜŞTERİ: " + item.customer_full_name + " MÜŞTERİ TELEFONU: " + item.customer_phone,
className: "fc-event-danger fc-event-solid-warning",
startRecur: currentValue,
endRecur: currentValue
},
{
title: 'Randevu',
//start: YM + '-14T13:30:00',
start: _user.user_appointments[0].appointment_time,
description: "ADRES: " + _user.user_appointments[0].appointment_place + " MÜŞTERİ: " + _user.user_appointments[0].customer_full_name,
//description: _user.user_appointments.appointment_time,
end: _user.user_appointments[0].appointment_time,
className: "fc-event-success",
}
],
eventRender: function (info) {
var element = $(info.el);
if (info.event.extendedProps && info.event.extendedProps.description) {
if (element.hasClass('fc-day-grid-event')) {
element.data('content', info.event.extendedProps.description);
element.data('placement', 'top');
KTApp.initPopover(element);
} else if (element.hasClass('fc-time-grid-event')) {
element.find('.fc-title').append('<div class="fc-description">' + info.event.extendedProps.description + '</div>');
} else if (element.find('.fc-list-item-title').lenght !== 0) {
element.find('.fc-list-item-title').append('<div class="fc-description">' + info.event.extendedProps.description + '</div>');
}
}
}
});
calendar.render();
}
}
};
}();
I am trying to solve title: 'Hatırlatıcı' part in events.