я играю с планировщиком jqwidget и после того, как я реализовал внешний ресурс / php для получения встреч, он выдает следующую ошибку:
Uncaught TypeError: Cannot read property 'jqxAppointment' of undefined
at a.(anonymous function).getJQXAppointmentByElement
Кусок, на который он жалуется:
getAppointmentElement: function(a) {
var b = null;
a.className.indexOf("jqx-scheduler-appointment") >= 0 && a.className.indexOf("jqx-scheduler-appointment-inner-content") == -1 && a.className.indexOf("jqx-scheduler-appointment-content") == -1 && a.className.indexOf("jqx-scheduler-appointment-resize-indicator") == -1 && (b = a);
for (var c = a, d = 0; d < 4 && c.parentNode; d++) c.className.indexOf("jqx-scheduler-appointment") >= 0 && c.className.indexOf("jqx-scheduler-appointment-innter-content") == -1 && c.className.indexOf("jqx-scheduler-appointment-content") == -1 && c.className.indexOf("jqx-scheduler-appointment-resize-indicator") == -1 && (b = c), c = c.parentNode;
return b
},
getJQXAppointmentByElement: function(a) {
var b = this,
c = a.getAttribute ? a.getAttribute("data-key") : a.attr("data-key");
if (c.indexOf(".") >= 0) var d = c.substring(0, c.indexOf(".")),
e = (c.substring(c.indexOf(".") + 1), b.appointmentsByKey[d]),
f = e.jqxAppointment.renderedAppointments[c];
else var e = b.appointmentsByKey[c],
f = e.jqxAppointment; <-- COMPLAINING
return f
},
Вот мой фрагмент:
<script type="text/javascript">
$(document).ready(function() {
var source = {
dataType: 'json',
dataFields: [{
name: 'id'
},
{
name: 'description'
},
{
name: 'location'
},
{
name: 'subject'
},
{
name: 'calendar'
},
{
name: 'start'
},
{
name: 'end'
},
{
name: 'status'
},
],
url: './includes/incCalendar/test.php',
**id:'id',**
};
var adapter = new $.jqx.dataAdapter(source);
$("#scheduler").jqxScheduler({
date: new $.jqx.date('todayDate'),
width: '100%',
height: 600,
rowsHeight: 50,
dayNameFormat: "abbr",
source: adapter,
columns: [{
name: 'id',
datafield: 'id'
},
{
name: 'description',
datafield: 'description'
},
{
name: 'location',
datafield: 'location'
},
{
name: 'subject',
datafield: 'subject'
},
{
name: 'calendar',
datafield: 'calendar'
},
{
name: 'start',
datafield: 'start'
},
{
name: 'end',
datafield: 'end'
},
{
name: 'status',
datafield: 'status'
}
],
showLegend: true,
/**
* called when the context menu is created.
* @param {Object} menu - jqxMenu's jQuery object.
* @param {Object} settings - Object with the menu's initialization settings.
*/
contextMenuCreate: function(menu, settings) {
var source = settings.source;
source.push({
id: "delete",
label: "Delete Appointment"});
source.push({
id: "status",
label: "Set Status",
items: [{
label: "Free",
id: "free"},
{
label: "Out of Office",
id: "outOfOffice"},
{
label: "Tentative",
id: "tentative"},
{
label: "Busy",
id: "busy"}
]
});
},
/**
* called when the user clicks an item in the Context Menu. Returning true as a result disables the built-in Click handler.
* @param {Object} menu - jqxMenu's jQuery object.
* @param {Object} the selected appointment instance or NULL when the menu is opened from cells selection.
* @param {jQuery.Event Object} the jqxMenu's itemclick event object.
*/
contextMenuItemClick: function(menu, appointment, event) {
var args = event.args;
switch (args.id) {
case "delete":
$("#scheduler").jqxScheduler('deleteAppointment', appointment.id);
return true;
case "free":
$("#scheduler").jqxScheduler('setAppointmentProperty', appointment.id, 'status', 'free');
return true;
case "outOfOffice":
$("#scheduler").jqxScheduler('setAppointmentProperty', appointment.id, 'status', 'outOfOffice');
return true;
case "tentative":
$("#scheduler").jqxScheduler('setAppointmentProperty', appointment.id, 'status', 'tentative');
return true;
case "busy":
$("#scheduler").jqxScheduler('setAppointmentProperty', appointment.id, 'status', 'busy');
return true;
}
},
/**
* called when the menu is opened.
* @param {Object} menu - jqxMenu's jQuery object.
* @param {Object} the selected appointment instance or NULL when the menu is opened from cells selection.
* @param {jQuery.Event Object} the open event.
*/
contextMenuOpen: function(menu, appointment, event) {
if (!appointment) {
menu.jqxMenu('hideItem', 'delete');
menu.jqxMenu('hideItem', 'status');
} else {
menu.jqxMenu('showItem', 'delete');
menu.jqxMenu('showItem', 'status');
}
},
/**
* called when the menu is closed.
* @param {Object} menu - jqxMenu's jQuery object.
* @param {Object} the selected appointment instance or NULL when the menu is opened from cells selection.
* @param {jQuery.Event Object} the close event.
*/
contextMenuClose: function(menu, appointment, event) {},
exportSettings: {
fileName: null
},
ready: function() {
// $("#scheduler").jqxScheduler('ensureAppointmentVisible', '1');
},
resources: {
colorScheme: "scheme05",
dataField: "calendar",
orientation: "vertical",
source: new $.jqx.dataAdapter(source)
},
appointmentDataFields: {
from: "start",
to: "end",
id: "id",
status: "status",
description: "description",
location: "location",
subject: "subject",
resourceId: "calendar"},
dayNameFormat: "full",
view: 'timelineDayView',
views: [{
type: 'timelineDayView',
appointmentHeight: 25,
timeSlotWidth: 15,
appointmentsRenderMode: "exactTime",
timeRuler: {
scale: "quarterHour",
formatString: "HH:mm",
scaleStartHour: 6,
scaleEndHour: 23
}
},
{
type: 'timelineWeekView',
appointmentHeight: 25,
timeSlotWidth: 15,
appointmentsRenderMode: "exactTime",
timeRuler: {
scale: "quarterHour",
formatString: "HH:mm",
scaleStartHour: 6,
scaleEndHour: 23
}
},
{
type: 'timelineMonthView',
appointmentHeight: 25,
timeSlotWidth: 15,
appointmentsRenderMode: "exactTime",
timeRuler: {
scaleStartHour: 6,
scaleEndHour: 23
}
},
{
type: 'agendaView',
appointmentHeight: 50,
timeSlotWidth: 15,
appointmentsRenderMode: "exactTime",
timeRuler: {
formatString: "HH:mm",
scaleStartHour: 6,
scaleEndHour: 23
}
},
{
type: 'dayView',
appointmentHeight: 50,
appointmentsRenderMode: "exactTime",
timeRuler: {
scale: "quarterHour",
formatString: "HH:mm",
scaleStartHour: 6,
scaleEndHour: 23
}
},
{
type: 'weekView',
appointmentHeight: 50,
appointmentsRenderMode: "exactTime",
timeRuler: {
scale: "quarterHour",
scaleStartHour: 6,
scaleEndHour: 23
}
}
]
});});
</script>
Я понял, в исходном адаптере отсутствовал этот фрагмент: я сделал’,
Задача ещё не решена.
Других решений пока нет …