2013-03-06 59 views
1
第二天

我使用以下的日曆在我的應用 jquery-week-calendarjQuery的周曆變化上一個星期和下個星期按鈕前一日和

我想改變上一個和下一個按鈕,使得點擊時它會到prev和next week以外的前一天和第二天。

我是jquery的新手,我能夠找到導致此問題的代碼的一部分。

prevWeek : function() { 
    //minus more than 1 day to be sure we're in previous week - account for daylight savings or other anomolies 
    var newDate = new Date(this.element.data("startDate").getTime() - (MILLIS_IN_WEEK/6)); 
    this._clearCalendar(); 
    this._loadCalEvents(newDate); 
    }, 

    /* 
    * Go to the next week relative to the currently displayed week 
    */ 
    nextWeek : function() { 
    //add 8 days to be sure of being in prev week - allows for daylight savings or other anomolies 
    var newDate = new Date(this.element.data("startDate").getTime() + MILLIS_IN_WEEK + (MILLIS_IN_WEEK/7)); 
    this._clearCalendar(); 
    this._loadCalEvents(newDate); 
    } 



    _loadCalEvents : function(dateWithinWeek) { 

    var date, weekStartDate, endDate, $weekDayColumns; 
    var self = this; 
    var options = this.options; 
    date = dateWithinWeek || options.date; 
    weekStartDate = self._dateFirstDayOfWeek(date); 
    weekEndDate = self._dateLastMilliOfWeek(date); 

    options.calendarBeforeLoad(self.element); 

    self.element.data("startDate", weekStartDate); 
    self.element.data("endDate", weekEndDate); 

    $weekDayColumns = self.element.find(".wc-day-column-inner"); 

    self._updateDayColumnHeader($weekDayColumns); 

    //load events by chosen means 
    if (typeof options.data == 'string') { 
     if (options.loading) options.loading(true); 
     var jsonOptions = {}; 
     jsonOptions[options.startParam || 'start'] = Math.round(weekStartDate.getTime()/1000); 
     jsonOptions[options.endParam || 'end'] = Math.round(weekEndDate.getTime()/1000); 
     $.getJSON(options.data, jsonOptions, function(data) { 
      self._renderEvents(data, $weekDayColumns); 
      if (options.loading) options.loading(false); 
     }); 
    } 
    else if ($.isFunction(options.data)) { 
     options.data(weekStartDate, weekEndDate, 
       function(data) { 
       self._renderEvents(data, $weekDayColumns); 
       }); 
    } 
    else if (options.data) { 
      self._renderEvents(options.data, $weekDayColumns); 
     } 

    self._disableTextSelect($weekDayColumns); 


    } 

回答

2

我希望你有添加的功能,休息的壓延機:

你使用可以這樣做:

prevWeek : function() { 

    var newDate = new Date(this.element.data("startDate")); 
    newDate = this._addDays(newDate , -1); 
    this._clearCalendar(); 
    this._loadCalEvents(newDate); 
    }, 

    nextWeek : function() { 

    var newDate = new Date(this.element.data("startDate")); 
    newDate = this._addDays(newDate , 1); 
    this._clearCalendar(); 
    this._loadCalEvents(newDate); 
    } 
相關問題