Calendar
Calendar copied to clipboard
how to use ajax to change markdata
Hi Brother,
I have sample code to reload the data via clicking the button. I hope it helps to you. In ajax after return successfully then change the data then do reload.
The sample that i will provide is via button click to reload, to reload the calendar.
Here's the example.
IN HTML
<div id="demo"> <h2>Inline calendar</h2> <div id="calendar-box"> <div id="calendar"> Loading calendar </div> </div> <button type="button" id="load-data">LOAD DATA</button> </div>
THE SCRIPT ` var now = new Date(); var year = now.getFullYear(); var month = now.getMonth() + 1; var date = now.getDate();
var data = [{
date: year + '-' + month + '-' + (date - 1),
value: 'hello',
},{
date: '2018-10-7',
value: 'marknelpogi',
}
];
$('#load-data').click(function() {
loadCalendar();
});
function loadCalendar() {
$('#calendar-box').html("<div id='calendar'></div>");
// inline
$('#calendar').calendar({
// view: 'month',
width: 320,
height: 320,
// startWeek: 0,
// selectedRang: [new Date(), null],
weekArray: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
data: data,
monthArray: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
date: new Date(),
onSelected: function (view, date, data) {
console.log('view:' + view)
console.log('date:' + date)
console.log('data:' + (data || '无'));
},
viewChange: function (view, y, m) {
console.log(view, y, m)
}
});
console.log("reload");
}
`