fullCalendar -未捕获的类型错误:不能调用方法'split'的定义

fullCalendar - Uncaught TypeError: Cannot call method 'split' of undefined

本文关键字:调用 方法 定义 split 不能 错误 类型 fullCalendar      更新时间:2023-09-26

我正在填充一个页面上的所有月份,例如:

<?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
});

用户month全局变量,然后设置

var month = $('.calenderSales').attr("id").split("_")[1];
$('.calenderSales').fullCalendar({
       editable: false,
       events:  { url: 'calender-events.php' },
       firstDay:1,
       month: month,
       year: 2013
});

.prop()代替.attr()

尝试在$(window).load(function());

内包装代码