我试图从数据库中获取结果将它们放入数组中,通过javascript获取它们并检查是否设置了值。
CalendarController.php
public function tasks($id)
{
$tasks = task::Findtasks()->select('tasks.*', 'tasks_times.*', 'tasks.name as title')
->where('project_id', '=', $id)
->join('tasks_times', 'tasks.id', '=', 'tasks_times.task_id')
->get();
return view('testcalendar', compact('tasks'));
}
你可以看到我给视图提供任务..
现在我在" testcalendar"的脚本标签中有这段javascript脚本。图。
eventAfterRender: function (event, element, view) {
var dataHoje = new Date();
var completed = <?php echo json_encode($tasks); ?>;
var tasks = JSON.parse('<?php echo json_encode($tasks); ?>')
for (var i = 0; i < completed.length; i++) {
if (completed[i]['completed'] == 1) {
//event.color = "Groenoe";
element.css('background-color', '#0eb505');
} else if (event.start < dataHoje && event.end < dataHoje) {
//event.color = "Rood";
element.css('background-color', '#fc0000');
} else if (event.start > dataHoje && event.end > dataHoje) {
//event.color = "Blauw";
element.css('background-color', '#27bec6');
}
}
},
所以当&#34;完成&#34; = 1我希望背景颜色变为绿色。 (是完成是数据库中的一列)
谢谢