'editEvent reload page even if nothing change
When I click on an event in my calendar (made with fullcalendar3) it apparead a modal where I can change name, start and end of the event. When I close this modal it reload the page, no matter if i change something or not.
Is there a way to stop the page from reload if I dont make changes?
This is my function to edit events in JS:
eventClick: function eventClick(event) {
$('#editNewEvent').modal('show').one('hidden.bs.modal', function (e) {
event.title = $('#editEname').val();
event.start = $('#editStarts').val();
event.end = $('#editEnds').val();
event.descrizione = $('#editDescrizione').val();
$.ajax({
url: 'eventi/updateEvent.php',
type: 'POST',
data: {start: event.start, _id: event.idAssenza, end: event.end, title: event.title, descrizione: event.descrizione},
success: function() {
location.reload();
}
});
$('#calendar').fullCalendar('updateEvent', event._id);
});
}
I found online this kind of solution:
success: function(data) {
var result = data;
location.reload();
}
});
return result;
But it doesnt change anything, still reload the page even if I dont modify anything
Solution 1:[1]
From an other question of mine I had this solution:
eventClick: function eventClick(event) {
$('#editNewEvent').modal('show');
//*salva* is the ID of my button
$("#salva").click(function() {
event.title = $('#editEname').val();
event.start = $('#editStarts').val();
event.end = $('#editEnds').val();
event.descrizione = $('#editDescrizione').val();
$.ajax({
url: 'eventi/updateEvent.php',
type: 'POST',
data: {start: event.start, _id: event.idAssenza, end: event.end, title: event.title, descrizione: event.descrizione},
success: function() {
location.reload();
}
});
$('#calendar').fullCalendar('updateEvent', event._id);
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aim0d |
