gpt4 book ai didi

javascript - 如何在 jquery Fullcalendar 事件中使用循环?

转载 作者:行者123 更新时间:2023-11-30 12:31:15 25 4
gpt4 key购买 nike

您好,我正在尝试在 jquery Fullcalendar 事件中循环,但我不知道为什么这不起作用:

var birthdaysList = @Html.Raw(Json.Encode(@ViewBag.birthdaysList));

$(document).ready(function () {

$('#calendar').fullCalendar({
lang: 'es',
header: {
left: 'title',
center: '',
right: 'prev,next today'
//right: 'month,agendaWeek,agendaDay'
},
eventLimit: true, // allow "more" link when too many events

events: //My loop here for title: birthdaysList.name , start birthdaysList.date

});
});

最佳答案

好的,首先,你不能在 envents: 中做一个循环,你必须创建一个数组,然后从 envents: 中调用它,就像这样:

var birthdaysList = @Html.Raw(Json.Encode(@ViewBag.birthdaysList));

var events = []; //The array
for(var i =0; i < birthdaysList.length; i++)
{events.push( {title: birthdaysList[i].name , start: birthdaysList[i].date})}


$(document).ready(function () {

$('#calendar').fullCalendar({
lang: 'es',
header: {
left: 'title',
center: '',
right: 'prev,next today'
//right: 'month,agendaWeek,agendaDay'
},
eventLimit: true, // allow "more" link when too many events

events: events

});
});

关于javascript - 如何在 jquery Fullcalendar 事件中使用循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27639027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com