dongnuan7956 2011-01-01 16:15
浏览 66
已采纳

未在fullCalendar中显示的事件

I want to add some Events after the fullCalendar object is create... I'm working with PHP and JavaScript.

I have create fullCalendar object and after i want to add some events.

Here is the PHP code:

  function BuildEvents() { 
    // Showing the calendar 
    echo '<div id="fCald"></div>';

   // Events building
   $evJSON = json_encode(array(
      array('title' => "Evt.1", 
           'start' => "2010-12-22", 
       'url' => "#"),
      array('title' => "Evt.2", 
       'start' => "2011-01-15", 'end' => "2011-01-19",
       'url' => "http://yahoo.com/")
   ));

   // Adding Events to object
   $fCal = '$("#fCald").fullCalendar("addEventSource", '.$evJSON.')';

   //Final showing      
   echo '<script type="text/javascript">'.
        'eval('.$fCal.');'.
        '</script>';
}

When PHP function is call, the JSON array is OK, but the events are not showing on the calendar...

I also test this code:

$fCal = '$("#fCald").fullCalendar("renderEvent", '.$evJSON.', true)';

and this is not working to...

I don't understand how to display events after building the fullCalendar object.

Thanks.

Luc M.

  • 写回答

1条回答

  • duandong2562 2011-01-01 19:22
    关注

    There's an easy/straight forward example in the plugin page:

    $(document).ready(function() {
        $('#calendar').fullCalendar({
            editable: true,
            events: "json-events.php",
            eventDrop: function(event, delta) {
                alert(event.title + ' was moved ' + delta + ' days
    ' +
                    '(should probably update your database)');
            },
            loading: function(bool) {
                if (bool) $('#loading').show();
                else $('#loading').hide();
            }
        });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题