1
予定の開始時刻を変更する方法はありますか?開始時刻(!)をfullcalendar.jsで更新するには
イベントは、このような外部ソースから来ている:
//initialize the external events
$('#external-events .fc-event').each(function() {
/* // store data so the calendar knows to render an event upon drop
$(this).data('event', {
title: $.trim($(this).text()), // use the element's text as the event title
stick: true // maintain when user navigates (see docs on the renderEvent method)
});
*/
var eventObject = {
title: $.trim($(this).text()), // use the element's text as the event title
id: $(this).data('id')
};
// store the Event Object in the DOM element so we can get to it later
$(this).data('eventObject', eventObject);
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
私は開始時刻とタイトルを更新/変更したい - 必要に応じて - モーダルダイアログでのイベントで。それはうまくいくようですが、別のイベントをドラッグして追加するたびに変更したい場合は、ドラッグされた他のすべてのイベントも変更します。
eventClick: function(calEvent, jsEvent, view) {
//Sending data to modal:
$('#modal').modal('show');
$("#input_title").val(calEvent.title);
var my_time = moment(calEvent.start).format('LT');
$("#input_time").val(my_time);
var my_date = moment(calEvent.start).format("YYYY-MM-DD");
$("#input_date").val(my_date);
// waiting for button 'save' click:
$('.btn-primary').on('click', function (myEvent) {
calEvent.title = $("#input_title").val();
var my_input_time = $("#input_time").val();
var momentTimeObj = moment(my_input_time, 'HH:mm:ss');
var momentTimeString = momentTimeObj.format('HH:mm:ss');
var my_input_date = $("#input_date").val();
var momentDateObj = moment(my_input_date, 'YYYY-MM-DD');
var momentDateString = momentDateObj.format('YYYY-MM-DD');
calEvent.start = moment(momentDateString + ' ' + momentTimeString, "YYYY-MM-DD HH:mm");
$('#calendar').fullCalendar('updateEvent', calEvent);
$('#calendar').fullCalendar('unselect');
$('#modal').modal('hide');
});
}
私は間違っていますか?
開始時刻または終了時刻を更新してからそれを再度更新する場合は、開始時刻の値は何ですか?ページロードのイベントを最初にレンダリングするとき、これは次のようになります: "2017-10-30 12:30"しかし、私は更新を行うと、次のような配列に変わります:[2017、9、30、0、 30,0,0]である。これはあなたにも起こりますか?編集: –
編集:私はこの問題を私のajax成功の呼び出しでrefetchEventsを使用して解決することができました。 –