Answer the question
In order to leave comments, you need to log in
How to pass parameters to js library?
Good day!
In the project I use Calendario.js to create an event calendar.
After loading the page and initializing the calendar, I send an ajax request, where I receive data about events in json format.
Upon successful receipt of data, I loop through all the elements, and try to create an event in the calendar for each.
$.ajax({
type: "POST",
url: '/ajax/getListEvent.php',
dataType: 'json',
data: ({
action:'getlist',
month: 3,
year: 2017,
}),
success: function(data) {
$.each(data, function(i, item) {
var date = item.date;
var img = item.img;
cal.setData({
date : '<img src="'+img+'" />'
//'03-31-2017' : '<img src="/upload/558/114_80_2/123.jpg" />'
});
});
}
});
if(/^\d{2}-\d{2}-\d{4}/.test(key) || /^\d{2}-\d{2}-YYYY/.test(key) || /^\d{2}-DD-YYYY/.test(key) || /^MM-\d{2}-YYYY/.test(key) ||
/^\d{2}-DD-YYYY/.test(key) || /^MM-\d{2}-\d{4}/.test(key) || /^\d{2}-DD-\d{4}/.test(key) || key == 'TODAY') {} else
console.log(key + ' is an Invalid Date. Date should not contain spaces, should be separated by \'-\' and should be in the ' +
'format \'MM-DD-YYYY\'. That ain\'t that difficult!');
console.log(key, val);
date <img src="/upload/558/114_80_2/123.jpg" />
cal.setData({
'03-31-2017' : '<img src="/upload/558/114_80_2/123.jpg" />'
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question