2015-04-05 95 views
2

我在每天/細胞中添加了('+')按鈕。如何添加任何事件在fullcalendar點擊按鈕?

var add_button = '<input type="button" value="+" />'; 
$(".fc-day-number").prepend(add_button); 

calendar with each cells having button to add event

如何寫這個點擊這個( '+')按鈕後,添加事件,能夠做同樣的在任何一天的點擊:

dayClick: function(date) { 
       addEvent(date);     
      }, 

function addEvent(date) { 
    var newEvent = { 
    title: timeSlot, 
    start: date.format() 
    }; 
} 

回答

0

當點擊該按鈕即可打開對話框。對話是一種接受價值的形式。當表單被保存時,您可以執行jquery ajax調用以將其保存到存儲中。

dayClick: function (date, allDay, jsEvent, view) { 
      $('#eventTitle').val(""); 
      $('#eventDate').val($.fullCalendar.formatDate(date, 'dd/MM/yyyy')); 
      $('#eventTime').val($.fullCalendar.formatDate(date, 'HH:mm')); 
      ShowEventPopup(date); 
     }, 

function ShowEventPopup(date) { 

    $('#popupEventForm').modal('show'); 
    $('#eventTitle').focus(); 
} 

$('#btnPopupSave').click(function() { 

    $('#popupEventForm').hide(); 

    var dataRow = { 
     'Title': $('#eventTitle').val(), 
     'NewEventDate': $('#eventDate').val(), 
     'NewEventTime': $('#eventTime').val(), 
     'NewEventDuration': $('#eventDuration').val() 
    } 

    ClearPopupFormValues(); 

    $.ajax({ 
     type: 'POST', 
     url: "/Diary/SaveEvent", 
     data: dataRow, 
     success: function (response) { 
      if (response == 'True') { 
       $('#calendar').fullCalendar('refetchEvents'); 
       alert('New event saved!'); 
      } 
      else { 
       alert('Error, could not save event!'); 
      } 
     } 
    }); 
}); 
+0

看看在asp.net這個解決方案MVC http://www.codeproject.com/Articles/638674/Full-calendar-A-complete-web-diary-system-for-jQue – 2015-04-05 09:01:43

+0

實際上我不能使用任何對話框,我必須添加點擊該('+')按鈕的事件, function addEvent(date){ var newEvent = { title:timeSlot, start:date.format() }; } 這裏的時隙是全局變量,其值由用戶設置。 – nirux 2015-04-05 14:54:42

相關問題