Reputation: 21
I'm trying to insert an event to my fullcalendar
and let it be there when i refresh the page but it's disappeared for some reason.
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
selectable: true,
selectHelper: true,
select: function(start, end) {
var title = prompt('Event Title:');
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true);
}
$('#calendar').fullCalendar('unselect');
},
})
});
</script>
I have try to change the code as well so it look samthing like this
if (title)
{
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay },
true
);
}
calendar.fullCalendar('unselect');
},
but i just got nothing on the page like i missing something
Upvotes: 0
Views: 891
Reputation: 10003
The data disappears when you refresh the page because you haven't saved the new event anywhere, nor do you have any functions to retrieve the previously-saved events. The new event exists solely within browser document. As soon as you leave the page, the document's data is discarded.
You need to save the data somewhere—client-side or server-side—then you need to retrieve that saved data each time the page loads. Traditionally programmers store data server-side, usually in databases. Client-side storage stores data in the browser and can be useful if users only need to access their own data but comes with many limitations (e.g., your work computer and home computer will have different saved data).
Upvotes: 1