Ajax call to approve a calendar event
Permalink
I am trying to add a new menu item in the calendar where admins can easily approve a calendar event. I copied the \concrete\single_pages\dashboard\calendar\events.php file into \application\single_pages\dashboard\calendar\events.php and I made the following addition to the code:
For the life of me I can't figure out how to do a successful ajax call to approve the event. Initially I couldn't figure out how to create the link item as a clickable element that didn't actually go anywhere, so that's where I ended up adding the 'onclick' attribute. Then I think I've narrowed it down to calling /ccm/calendar/event/version/approve but I started running into issues with the ccm_token and doing a regular jQuery ajax call. Is this the wrong approach? Should I be doing something different here?
Thanks in advance!
foreach ($results as $occurrence) { $menu = new \Concrete\Core\Calendar\Event\Menu\EventOccurrenceMenu($occurrence); $menuHelper = Core::make('helper/concrete/ui/menu'); $newMenuItem = new Concrete\Core\Application\UserInterface\ContextMenu\Item\LinkItem('javascript:;', t('Approve Event'), ['onclick'=>'approveEvent('.$occurrence->getID().');']); $menu->addItem($newMenuItem); ...
For the life of me I can't figure out how to do a successful ajax call to approve the event. Initially I couldn't figure out how to create the link item as a clickable element that didn't actually go anywhere, so that's where I ended up adding the 'onclick' attribute. Then I think I've narrowed it down to calling /ccm/calendar/event/version/approve but I started running into issues with the ccm_token and doing a regular jQuery ajax call. Is this the wrong approach? Should I be doing something different here?
Thanks in advance!
and then the JS function: