2016-07-21 46 views
3

fullcalendar v2リソースカレンダーを実装しました。私が修正できないのは、動的に設定することですmintimemaxTimeを基準にしています。毎日仕事のタイミングが異なります。FullcalendarがminTimeとmaxTimeを動的に設定しました

$('#calendar').fullCalendar({ 
header: { 
    left: 'prev,next today', 
    center: 'title', 
    right: 'month,agendaWeek,resourceDay' 
}, 
defaultView: 'resourceDay', 
titleFormat: {'day':'dddd, MMMM D'}, 
minTime: "08:00", 
maxTime: "20:00", 
scrollTime: moment().format('H:m'), 
eventLimit: true, // allow "more" link when too many events 
resources:[ 
    resource1,resource2 
    ], 
slotDuration: '00:15:00', 
allDaySlot: false, 
lazyFetching: false, 
droppable: true, 
defaultTimedEventDuration: '00:30:00', 
selectable: true, 
selectHelper: true, 
unselectAuto: 'true', 
timeFormat: {'agenda':'hh:mm A','':'hh:mm A'}, 

// Calender Method-1: AJAX events will loaded from this code 
events:function(start, end, timezone,callback) { 

$.ajax({ 
     url: "http://www.domainn.com/dashboard/index", 
     dataType: 'json', 
     type:'POST', 
     // async: false, //blocks window close 
     data: { 
      start: start.unix(), 
      end: end.unix(), 
      viewtype: $('#calendar').fullCalendar('getView').name, 
     }, 
     success:function(response){ 
      var calendarOptions = $('#calendar').fullCalendar('getView').calendar.options; 
      // console.log(calendarOptions); 
     calendarOptions.minTime = response.timings.start; 
      calendarOptions.maxTime = response.timings.end; 

      $('#calendar').fullCalendar('destroy'); 

      $("#calendar").fullCalendar(
       $.extend(calendarOptions, { 
        events:response.resources 
       }) 
     ); 


     } 
    }); 
}, 
eventRender: function (event, element) { 
    // code here 
}, 
// other events follows..... 
}); 

月曜日10時

が、私はこのように私のカレンダーをinitilizedていた... 24:00まで火曜日16時午後2時

このajaxコールから、その日の動的な仕事のタイミングが得られ、

と設定しようとしています。
response.timings.start 
response.timings.end 

しかし、これらのオプションを使用して、他の日に/ goingToを変更すると、イベントは取得されません。 基本的に、同じ関数をループ内で無限に呼び出し続けます。

多くのオプションを試しましたが、運はありませんでした。どんなヘルプ/ガイドも非常に高く評価されます。ありがとう。

+0

https://jsfiddle.net/を追加できますか? – fehrlich

+0

解決しましたか?バージョン2.9.0のFCを使用できない場合は、最小時間と最大時間を設定した後、$( '#calendar')を呼び出すイベントを取得できるはずです。fullCalendar( 'render');カレンダーを破壊するのではなく、 –

答えて

2

バージョン2.9.0以降FullCalendarはsetting options dynamicallyをサポートしています。

あなたはこのような何か行うことができる必要があります:私は人々がオプションにあなたが持っている方法を設定しようとしている他のSOの記事を見てきました

$('#calendar').fullCalendar('option', 'minTime', response.timings.start); 

を、いくつかは、それが働いたと他の人はそれがなかったと言っています。

GitHub issueこの機能をリクエストしてください。

GitHub issueこの機能を実装しました。

+0

私はこのオプションを試しましたが、これは機能しません。私はリソースの設定で2.0.2を使用しています。 – Tarunn

+0

あなたは$( '#calendar')に疲れましたか?fullCalendar( 'render');カレンダーを破壊するよりも? –

関連する問題