同じ JS ファイル内で「eventNew」関数を呼び出すことができるかどうかを知りたいです。別の関数から「eventNew」関数にアクセスしようとしています。
コードの一部を次に示します。
$calendar.weekCalendar({
displayOddEven: true,
timeslotsPerHour: 4,
allowCalEventOverlap: true,
overlapEventsSeparate: true,
firstDayOfWeek: 1,
businessHours: { start: 1, end: 24, limitDisplay: true },
daysToShow: 7,
switchDisplay: { '1 day': 1, '3 next days': 3, 'work week': 5, 'full week': 7 },
title: function (daysToShow) {
return daysToShow == 1 ? '%date%' : '%start% - %end%';
},
height: function ($calendar) {
return $(window).height() - $("h1").outerHeight() - 1;
},
eventNew: function (calEvent, $event) {
var $dialogContent = $("#event_edit_container");
resetForm($dialogContent);
var startField = $dialogContent.find("select[name='start']").val(calEvent.start);
var endField = $dialogContent.find("select[name='end']").val(calEvent.end);
var titleField = $dialogContent.find("input[name='title']");
var bodyField = $dialogContent.find("textarea[name='body']");
$dialogContent.dialog({
modal: true,
title: "New Calendar Event",
close: function () {
$dialogContent.dialog("destroy");
$dialogContent.hide();
$('#calendar').weekCalendar("removeUnsavedEvents");
},
buttons: {
save: function () {
calEvent.id = id;
id++;
calEvent.start = new Date(startField.val());
calEvent.end = new Date(endField.val());
calEvent.title = titleField.val();
calEvent.body = bodyField.val();
SaveEvent(); // Modified
$calendar.weekCalendar("removeUnsavedEvents");
$calendar.weekCalendar("updateEvent", calEvent);
$dialogContent.dialog("close");
},
cancel: function () {
$dialogContent.dialog("close");
}
}
}).show();
$dialogContent.find(".date_holder").text($calendar.weekCalendar("formatDate", calEvent.start));
setupStartAndEndTimeFields(startField, endField, calEvent, $calendar.weekCalendar("getTimeslotTimes", calEvent.start));
}
});