2013-07-25 81 views
0

我使用eventSources方法初始化FullCalendar jQuery插件。fullcalendar初始化期間獲取日期

eventSources: initEvents(visibleStartDate,visibleEndDate) ]

其中initEvents是和AJAX調用,以返回到被渲染代表事件的JSON對象jsp頁面。它工作的很好,但現在我只想獲取日曆上可見日期的事件。我在文檔中閱讀過,我可以在View對象上使用visStart和visEnd來獲取日曆的開始和結束日,但我不知道在初始化我的eventSources時如何獲取這些信息。有沒有辦法?預先感謝您的回覆。

埃裏克

+0

我想我想出了我自己的問題:「開始」和「結束」參數由fullcalendar自動添加。更多詳細信息,請訪問:http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/ –

+0

請發佈答案,也許其他人將來也會遇到同樣的問題。 – nouney

+0

在我的JSP頁面中,我檢索如下開始日期:String start = request.getParameter(「start」); 日期startDate =新日期(Long.parseLong(start)* 1000);我會發布完整的代碼,一旦我確定它的一切工作:) –

回答

0

事實證明,fullcalendar插件將增加開始和結束HTTP參數時,日曆源是外部獲取。 http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

我的代碼(JavaScript的的搭配,JSP,JSF):

  1. FullCalendal初始化:全部細節在此文檔描述

page.view.calendar.fullCalendar(
{ 
.... 
eventSources: [ 
page.control.initEventSources(#{sessionBean.myCalendar.calendarConfgIdNbr},'Approved'),   
page.control.initCalendarHolidays(#{sessionBean.myCalendar.calendarConfgIdNbr})], 
.... 
}); 

2.我javascript功能: page.control.initEventSources:

var page = { 
      control : { 
       initEventSources : function(calConfId, status) { 
        return { 
         url: '/oceportal/tom/data/bookings.jsp', 
         type: 'POST', 
         data: { calConfId: calConfId, bookingStatus: status, loggedInId: "#{sessionBean.loggedInId}", }, 
         success: function(data) { }, 
         error: function() { alert('there was an error while fetching events!'); }, 
         color: 'none', 
         textColor: page.colorConfig[status] 
        }; 
       } 
      } 
     } 
  1. 我的JSP片段(檢索第一和最後一個可見的天數):

    
    String start = request.getParameter("start"); 
    Date startDt = new Date(Long.parseLong(start)*1000); 
    String end = request.getParameter("end"); 
    Date endDt = new Date(Long.parseLong(end)*1000); 
    

    希望它可以幫助別人。

相關問題