【发布时间】:2013-03-13 05:59:24
【问题描述】:
我正在填充页面上的所有月份,例如:
<?php foreach(range(0,11) as $month): ?>
<div style='float:left; width:303px;' id='calenderSalesMonth_<?php echo $month ?>' class='calenderSales'></div>
<?php endforeach; ?>
fullCalendar 应该通过id='calenderSalesMonth_*' 设置特定月份,它不起作用,我收到错误:
Uncaught TypeError: Cannot call method 'split' of undefined
代码:
$('.calenderSales').fullCalendar({
editable: false,
events: { url: 'calender-events.php' },
firstDay:1,
month: $(this).attr("id").split("_")[1],
year: 2013
});
【问题讨论】:
-
如果
.attr("id")返回undefined,则不能调用.split,因为.split是String对象的方法,不能在undefined上调用。 -
这段代码是否在某个
click事件处理程序中? -
@dfsq 不是。
-
@I'll-Be-Back 尝试使用
.prop() -
@DipeshParmar
.attr("id")returnUnexpected identifier- 不确定现在的解决方案是什么...?
标签: javascript jquery jquery-plugins fullcalendar