我想知道是否可以在同一個JS文件中調用「eventNew」函數。正如我試圖從不同的功能訪問「eventNew」功能。從內部調用JavaScript函數事件
在此先感謝
下面是代碼的一部分:
$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));
}
});