I put them in a situation I am making a web application that implements fullcalendar to create an agenda, in which by clicking on any day you show a modal window in which there is a form to register the event, but I I needed to use a select to load the types of vehicles which I achieved with this code:
getvehiculoss();
function getvehiculoss(){
$.ajax({
type: "GET",
url: "(aqui pongo la ruta de mi consulta)",
dataType: "json",
success: function(data){
$.each(data,function(key, registro) {
$("#SelectVehiculo").append('<option value='+registro.id_vehiculo+' data-icon="../../web/img/vehiculos/'+registro.foto+'">'+registro.placa+'</option>');
});
},
error: function(data) {
alert('error al traer los vehiculos');
}
});
}
and it works for me it loads the select and also makes the insert correctly taking the value of the select, my problem is already when I show the selected data to edit (I use the same modal to edit and add), well my idea was that when I clicked the event that I loaded your information in the modal fields and that I had the option to modify and correctly load all the data in function "eventClick" that has full calendar charge the data type like this:
eventClick: function(calEvent, jsEvent, view) {
//Abre la modal de ejemplo
$('#modalprueba').modal();
$('#modalprueba').modal('open');
*/
//tomo los valores y los cargo
$('#txtID').val(calEvent.id_agenda_clase);
$('#txtTitulo').val(calEvent.title);
//aqui intento hacer que seleccione el valor en mi select
$('#SelectVehiculo').val(calEvent.id_vehiculo);
}
(where "SelectVehicle" is the id of my select and "calEvent.id_vehicle", is what I get from my database), in theory it should work, but it does not, and try to put that same thing out of
$('#calendarioWeb').fullCalendar({"codigo del calendario"})
and if it changes for example I put
$('#SelectVehiculo').val(3);
I will load it exactly as it should, I've been reading for a long time and looking for information on how to do it and I can not find anything that works for me, if they helped me I would be very grateful, thank you