bootstrap-year-calendar
bootstrap-year-calendar copied to clipboard
How to use JSON for the DataSource
Hi there, I'm pretty new with this calendar and I don't know how to use my own JSON from a query on MySQL, to change the default DataSource in the example code. There is a guide for it or someone who can help me?
Thanks
Hi , you should look at #103 But basically when you get your response, do something like:
$.ajax({
url: "YourUrl!,
dataType: "json",
success: function(response) {
var data = [];
for (var i = 0; i < response.length; i++) {
data.push({
id: response[i].id,
name: response[i].name,
location: response[i].location,
startDate: new Date(response[i].startDate),
endDate: new Date(response[i].endDate),
color: response[i].color
});
}
$(e.target).data('calendar').setDataSource(data);
}
});