[英]JavaScript Array Fill
I have a question regarding the next code, how can I fill the 'events' array dynamically, with a for / while ? 我对下一个代码有疑问,如何使用for / while动态填充'events'数组? ( I can't fill it manually due to the fact that there are a lot of datas ) Thank you
(由于数据很多,我无法手动填写)谢谢
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek'
},
defaultDate: '2014-12-15',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'Test',
start: '2014-12-17'
}
]
});
});
</script>
You can create an array variable and then use it when you initialize the calendar like so: 您可以创建一个数组变量,然后在初始化日历时使用它,如下所示:
var events = [];
for(var i = 0; i < 10; i++) {
events.push({title: 'Test' + i, start: '2014-12-17'});
}
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek'
},
defaultDate: '2014-12-15',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: events
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.