2015-04-05 137 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