2017-04-11 61 views
6

以下のコードはFullCalendarのCustom Viewのドキュメントです。それは素晴らしいスタートのようですが、私のような新しいものでは、最もシンプルなカスタムビューを(いくつかのイベントで)レンダリングするいくつかの基本的なコードを持つことが非常に役に立ちます。 BasicViewとAgendaViewを参照するように指示していますが、それは私の理解をはるかに超えています。それぞれの関数はカスタムクラスでオーバーライドする必要がありますか?基本的なFullCalendarカスタムビューを作成する方法

このPlunkerには基本的なFullCalendarとカスタム表示に切り替えるボタンがあります。非常に役立つのは、実際の例を見ることです。私はカスタムビューのために何時間も失敗しています。 FullCalendarを知っていて、関数のコードを記入していただければ、非常に感謝しています!

https://plnkr.co/edit/gfEUCVYTWTm1md24e33m?p=preview

私の目標は、各エントリは最終的にはかなりのデータとCSSスタイルで肉付けされますスクロールのdiv(順番にその日のすべてのイベントを一覧表示日間のリストを構築することです - - 私listDayがこのタイプのカスタマイズを許可するかどうかは不明です)。

var FC = $.fullCalendar; // a reference to FullCalendar's root namespace 
var View = FC.View;  // the class that all views must inherit from 
var CustomView;   // our subclass 

CustomView = View.extend({ // make a subclass of View 

    initialize: function() { 
     // called once when the view is instantiated, when the user switches to the view. 
     // initialize member variables or do other setup tasks. 
    }, 

    render: function() { 
     // responsible for displaying the skeleton of the view within the already-defined 
     // this.el, a jQuery element. 
    }, 

    setHeight: function(height, isAuto) { 
     // responsible for adjusting the pixel-height of the view. if isAuto is true, the 
     // view may be its natural height, and `height` becomes merely a suggestion. 
    }, 

    renderEvents: function(events) { 
     // reponsible for rendering the given Event Objects 
    }, 

    destroyEvents: function() { 
     // responsible for undoing everything in renderEvents 
    }, 

    renderSelection: function(range) { 
     // accepts a {start,end} object made of Moments, and must render the selection 
    }, 

    destroySelection: function() { 
     // responsible for undoing everything in renderSelection 
    } 

}); 

答えて

1

カスタムビューを動作させるために、プランナーにいくつかの行を追加しました。ただ、言うまでも変更https://plnkr.co/edit/8iOq15CsL2x6RPt29wgE?p=preview

:カレンダーの初期化子で ビュー定義は、カスタムビューで

$('#calendar').fullCalendar({ 
... 
    views: { 
      CustomView: { 
       type: 'custom', 
       buttonText: 'my Custom View', 
       click: $('#calendar').fullCalendar('changeView', 'CustomView') 
      } 
     } 
}); 

を追加されましたが、ちょうどレンダリング

$('.fc-view').append("<div>Insert your content here</div").css("background", "red"); 
でこれを追加あなたはここに例を見つけることができますカスタムで

は、あなたがこれを行うことにより、イベントへのアクセスを取得し表示します。

var myEvents=$('#calendar').fullCalendar('clientEvents'); 

そこからさらにカスタマイズを行うことができます

関連する問題