fullcalendar添加&删除事件

时间:2014-11-07 03:51:49

标签: fullcalendar

我试图添加&只需单击它们即可删除事件,
它可以工作,但如果我改变月份,或者我再添加一个事件,它就不会起作用了。
有些东西不能正常工作:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
    },
    defaultDate: '2014-11-07',
    editable: true,
    eventLimit: true, // allow "more" link when too many events
    events: [{
        id: 'All Day Event',
        title: 'All Day Event',
        start: '2014-11-03'
    }, {
        id: 'popo',
        title: 'popo',
        start: '2014-11-04T10:30:00',
        end: '2014-11-04T12:30:00',
        description: 'This is a cool event',
        color: 'rgb(142, 67, 163)',
        textColor: 'white'
    }, {
        id: 'popo2',
        title: 'popo2',
        //url: 'http://google.com/',
        start: '2014-11-05'
    }]
});

$('.fc-day').click(function(){
    var myPrompt = prompt('');
    /*$('#calendar').fullCalendar('addEventSource', [{
        id: myPrompt,
        title: myPrompt,
        start: $(this).attr('data-date')
    }]);*/

    var newEvent = {
        id: myPrompt,
        title: myPrompt,
        start: $(this).attr('data-date')
    };
    $('#calendar').fullCalendar( 'renderEvent', newEvent , 'stick');

});

$('.fc-content').click(function(){
    var gugu = $(this).children('.fc-title').html();
    $('#calendar').fullCalendar('removeEvents', gugu);
});

我做错了什么?

Demo HERE

1 个答案:

答案 0 :(得分:1)

而不是 $('.fc-content').click(function(){ 使用 $('#calendar').on('click','.fc-content',function(){

所以它也适用于新的dinamicaly创建的事件。

相关问题