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

未在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();
            }
        });
    });
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题