未在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个回答



有一个简单/直接插件页面中的“rel =”nofollow“>示例:< / p>

  $(document).ready(function(){
$('#calendar')。fullCalendar({
editable:true,
events:“json- events.php“,
eventDrop:function(event,delta){
alert(event.title +'被移动'+ delta +'days
'+
'(应该更新你的数据库)');

},
loading:function(bool){
if(bool)$('#loading')。show();
else $('#loading')。hide();
} \ n});
});
</ code> </ pre>
</ div>

展开原文

原文

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

duanchun6148
duanchun6148 好! 我找到了解决方案。 在调用json_encode()之前,必须将utf8_encode()应用于标题文本...
9 年多之前 回复
doude2635
doude2635 too long
9 年多之前 回复
dousuitang5239
dousuitang5239 谢谢,它的工作! 在该示例中,文件是“/myfeed.php”,它们引用“根目录”。 现在,我使用“myfeed.php”并将文件放在“当前目录”中...
9 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐