Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ID of an event (Fullcalendar)

I need add an id to every single event from Fullcalendar, I found this http://arshaw.com/fullcalendar/docs/event_data/Event_Object/ but I don't know how, this id is
unique for every single event, because then I save the events in a Mysql database. Thanks

like image 939
Bryan Villafañe Avatar asked Apr 03 '13 03:04

Bryan Villafañe


People also ask

How do I get events on FullCalendar?

Calendar::getEvents Retrieves events that FullCalendar has in memory. This method will return an array of Event Objects that FullCalendar has stored in client-side memory.

How do I delete a FullCalendar event?

Event::remove Removes an event from the calendar. You must call this on an Event Object that you received elsewhere in the API, such as getEventById.

What is FullCalendar?

FullCalendar is a JavaScript library that seamlessly integrates with such popular JavaScript frameworks as Vue, React, Angular. Thanks to its excellent documentation, one won't have trouble incorporating the library into projects.

How do I change the color of an event in FullCalendar?

You can change the color of all events on the calendar like so: var calendar = new Calendar(calendarEl, { events: [ // my event data ], eventColor: '#378006' }); You can use any of the CSS color formats such #f00 , #ff0000 , rgb(255,0,0) , or red .


1 Answers

Clear Solution is

When you fetch events with Ajax also assign "id" that coming from DB

id:entry.id

$.ajax({ 
    url: '/eventsJson', 
    type: 'GET', 
    data: { }, 
    error: function() {
        alert('there was an error while fetching events!');
    } 
}).done(function (doc) { 

    var event = Array();
    $.each(doc, function(i, entry) {
        event.push({id:entry.id, title: entry.title, start: entry.start});
    });

Event Click

eventClick: function(event, jsEvent, view) {
               var title = prompt('Event Title:', event.title, { buttons: { Ok: true, Cancel: false} });

           if (title){
           event.title = title;

           var data = {
                'title':title
            };

           $.ajax({
             url: '/events/'+event.id,
             data: data,
             type: 'POST',
             dataType: 'json',
             success: function(response){
               if(response.status == 'success')
               $('#calendar').fullCalendar('updateEvent',event);
             },
             error: function(e){
               alert('Error processing your request: '+e.responseText);
             }
           });
           }
        }
like image 90
ErcanE Avatar answered Sep 28 '22 23:09

ErcanE