0
I was wondering if there’s any way I could put some event in the database by FullCalendar
,
I took the current version and saw that it has a function that it appears a prompt for me to type the event title, but this only in js so if I update the page it does not leave the event registered.
How can I do that? Follow the code below
$(document).ready(function() {
var currentLangCode = 'pt-br';
// build the language selector's options
$.each($.fullCalendar.langs, function(langCode) {
$('#lang-selector').append(
$('<option/>')
.attr('value', langCode)
.prop('selected', langCode == currentLangCode)
.text(langCode)
);
});
// rerender the calendar when the selected option changes
$('#lang-selector').on('change', function() {
if (this.value) {
currentLangCode = this.value;
$('#calendar').fullCalendar('destroy');
renderCalendar();
}
});
function renderCalendar() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: Date(),
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); // stick? = true
}
$('#calendar').fullCalendar('unselect');
},
eventClick: function(event) {
$(this).popover({html:true,title:event.title,placement:'top',container:'body',content: 'vamo ver se vai agora'}).popover();
},
lang: currentLangCode,
buttonIcons: false, // show the prev/next text
weekNumbers: true,
editable: false,
eventLimit: true, // allow "more" link when too many events
events: {
url: 'fullcalendar/demos/php/get-events.php',
},
loading: function(bool) {
$('#loading').toggle(bool);
}
});
}
renderCalendar();
});
Could you put in the code you used up to Gora? From what I saw the documentation there are methods to add events to the calendar, but I believe it can be adapted with an ajax to add to the bank.
– Rafael Withoeft
I changed the question and put the current JS code of my Library, I already figured out how to bring the bank results but did not understand how to insert them in the bank
– Jobson Anselmo Chinelli
This eventClick that would be responsible for generating a new event?
– Rafael Withoeft
Actually not this eventClick is responsible for appearing a little ballad with a description of the event in question. what would add an event supposedly be the select event
– Jobson Anselmo Chinelli
that when I click on some day appears the prompt for me to enter the title of Event and put it in the calendar but as this in js if I update the page it will disappear the event, I wonder if there is a way to insert this event in the bank to update the page the event does not disappear
– Jobson Anselmo Chinelli
I even thought about using a modal bootstrap to make the insertion form but I could not find a way to send the data to the database
– Jobson Anselmo Chinelli
Jobson, yes there are ways to do this... you remember the ajax?
$.ajax({url: 'url-destino-da-requisicao', method: 'POST', dataType: 'json', data {codigo_evento: 1, descricao_evento: "bla bla bla"}}.done(function(data){console.log("parece que deu certo!")}))
.... This you can add next to your select event or a separate function and call it.– Rafael Withoeft
yes, I understand but then if I use the bootstrap modal when I give the Submit it will go to the ajax function that is inside the select?
– Jobson Anselmo Chinelli
My intention would be the following I pick up when the user click on a day appear a modal with a form to register the event, then it registering the event would be fixed independent of give refresh on the page or not.
– Jobson Anselmo Chinelli
You can do that. As long as it is handled correctly... if it is a form within the modal, you intercept the Submit event and don’t let it refresh the page. He will not take the event from within the select, I do not know how it works... you told me that the select was what registered and changed the events...
– Rafael Withoeft
Ah yes now I understood how to do, eh only I intercept the Ubmit, and within the function of the Ubmit I put to send the data via ajax to record in the database. Thank you very much indeed. It really helped me, I was stuck in it :D
– Jobson Anselmo Chinelli