繁体   English   中英

遍历js函数参数

[英]Looping through js function parameter

我有下面的js。

$('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
      },
      editable: false,


      events: [
        {
          title: 'Absent',
          start: new Date(y, m, 9),
          color: '#008aaf '
        }
      ]


    });

上面的js为我生成了一个日历。 events参数在开始字段中指定的日期标记事件。 现在,我必须根据我的php 日期数组动态生成事件,如下所示:

   Array
    (
        [0] => 28/07/2014
        [1] => 30/07/2014
        [2] => 01/08/2014
        [3] => 29/07/2014
    )

如何基于php 日期数组生成事件?

那这样的东西呢?

$('#calendar').fullCalendar({
  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
  },
  editable: false,

  events: [
  <?php
    foreach($dateArray as $date)
    {
        $dateParts = explode("/",$date);
        $dates[] = "{
          title: 'Absent',
          start: new Date(".$dateParts[2].", ".$dateParts[1].", ".$dateParts[0]."),
          color: '#008aaf '
        }";
    }
    echo implode(",",$dates);
  ?>
  ]
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM