jQuery fullcalendar: contextmenu

前端 未结 3 1883
遇见更好的自我
遇见更好的自我 2021-02-04 19:57

I want to use jQuery.contextMenu:

http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin

In jQuery.fullcalendar when I right-click on an

3条回答
  •  逝去的感伤
    2021-02-04 20:28

    I used the Fullcalendar Loading callback: http://arshaw.com/fullcalendar/docs/event_data/loading/

    loading: function (bool, view) { 
    
        if (bool){
            jQuery('#com_jc_msg_saving').fadeIn();
        } else {
    
            jQuery('#com_jc_msg_saving').fadeOut();
    
            jQuery.contextMenu({
    
                selector: '.fc-event',//note the selector this will apply context to all events 
                trigger: 'right',
                callback: function(key, options) {
                    //this is the element that was rightclicked
                    console.log(options.$trigger.context);
    
                    switch(key)
                    {
                    case 'edit_event':
    
                      break;
                    case 'del_event':
    
                      break;
                    case 'add_event':
    
                      break;
    
                    }
    
                },
                items: {
                    'edit_event': {name: 'Edit'},
                    'del_event': {name: 'Delete'},
                    'add_event': {name: 'Create'},
                }
            });
        }
    },
    

    The thing is that you will need to get the event id from that element - what I did was use the className in the events json data. The just a bit of a string replace and you will have your id.

    'className' => 'jc_event_' . $event->id,

提交回复
热议问题