title: How add events in fullcalendar without wait for database adding
body: <p>I figured out how to add en event quickly in fullcalendar, The idea is add to calendar, display and after save to database, without wait for database, but then events recently added gets duplicate when going back a week and comeback.</p>
  <p>The code for add the event to calendar is this:</p>
  <pre><code>// First add the event to calendar, displaying almost instantly.
        var idTemp = Math.floor(Math.random() * 100000) + 1;
  
                          var event = {
                              id: idTemp,
                              title: TextoEvento,
                              start: CalendarInfoSelect.start,
                              end: CalendarInfoSelect.end,
                              allDay: false,
                              tituloOriginal: TextoEvento,
                              backgroundColor: colorEvento,
                              textColor: colorEventoTexto
                          };
                         calendar.addEvent(event );
  
                       // Then, add to database:
                                $.ajax({
                                  cache: false,
                                  url: '@Url.Action(&quot;EventAddedTareaReciente&quot;, &quot;CH&quot;)',
                                  type: &quot;POST&quot;,
                                  dataType: 'json',
                                  data: {
                                      id: Idbd,
                                      idAct: IdAct,
                                      idProy: IdProy,
                                      idProd: IdProd,
                                      newStart: CalendarInfoSelect.startStr,
                                      newEnd: CalendarInfoSelect.endStr,
                                      ini: CalendarInfoSelect.start.toISOString(),
                                      fin: CalendarInfoSelect.end.toISOString()
                                  },
                                  success: function (data) {
                                      if (data.Id &gt; 0) {
                                          event = calendar.getEventById(idTemp);
  
                                          // Here set id with database's one
                                          event.setProp('id', data.Id);
                                      }
                                      else {
                                          event = calendar.getEventById(idTemp);
                                          event.remove();
                                      }
                                  },
                                  error: function (xhr) {
                                      event = calendar.getEventById(idTemp);
                                      event.remove();
  
                                  }
                              });
  </code></pre>
  <p>There is no error here it's works fine.
  But when the user click to got one week back and comeback to the original week the event gets duplicate.</p>
  <p><a href="https://i.stack.imgur.com/kpAvz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kpAvz.png" alt="duplicate event" /></a></p>
  <p>If the user add several event this ways this events gets duplicate in calendar.<strong>But they are not duplicate in database</strong> when refresh browser (F5) the display it's perfectly fine.</p>
  <p>It's like the events add this way get sticky in memory.</p>
  <p>Any help, ideas? I can't find a solution. Maybe there is another way to do that.</p>
  <p>I use FullCalendar Core Package v4.3.1</p>
  <p>Thanks</p>